Docker – setup a container environment for development

What is Docker?

Docker is a computer program that performs operating-system-level virtualization”


Instead of creating a virtual machine to set up a dev environment, now we has another option 🙂

Install Docker CE

Docker CE is version for single user or development team.

To install Docker CE on Ubuntu, see

You can also find installation guide for other operation systems here (see left sidebar of the page).

Some basic commands

To work with docker, we need administrator privilege, if using Ubuntu we have to use sudo with each command, but I will not specify it here.

Firstly we have to pull an image (visit Docker Hub to looking for your needed image.):

docker pull <image name>

Next, we create a container to run. A container is what really running, you can image it as a “virtual machine”

docker run -it -name <container_name> <image_name>

The run command will create an container from pulled image then start-up your “virtual machine”.

Note that, each time we use run command, a new container is created. So, to start-up previous created container, we use start command:

docker start -ai <container_name>

Ok, above command is enough for us to create an working environment. In next part, I will mention to some related commands you may also need:

List pulled images:

docker images

Remove image:

docker rmi <image_name>

List created containers:

docker container ls -a

(If not specify option -a, only running container is listed)

Remove container:

docker container rm <container_name>

See docker’s used disk:

docker system df

Reference: Docker CLI

Run GUI application in container

I’ve tested it on a Linux system (Ubuntu). I have not found the way to make it work on Windows or Mac yet. In this way, we will share X-server of host machine with the container, so our program is really run in container but it GUI is display like a host machine’s application.

docker run -it --net=host -e DISPLAY=$DISPLAY -e \
--name <container_name> <image_name>

Now, from command line you can run your GUI application, for example geany. To prevent display output log in terminal, you can use nohup command:

nohup geany


Leave a Reply