Category Archives: Docker


If you need to have multiple instances of different ROS or Ubuntu version, one solution is a virtual machine which puts lots of overhead on the hardware and makes it very slow. A good alternative for this problem is Docker. Docker is a tool that can package an application and its dependencies in a virtual container that can run on any Linux server [1].

Basically, you create images and spin of containers from images that you can work with.


Here I have installed the docker community edition that on Ubuntu 16.04 (Xenial Xerus) [2].

1) First, make sure you don’t have any old version of docker on your system:

2) Add required packages:


3) Add Docker’s official GPG key:

4) Add the repository:


5) Install the docker:


6) Now you ready to start, but first fix the permission problem:


First example, PHP+Apache

First search in the for PHP and from the list pick apache, at the current time the latest stable Apache is 7.1.11-apache. Just like CMake, create a file and name it Dockerfile and add the following line into that:


create a src directory and add the index.php and simply put a hello world message in it:

now we ready to build it:

After a successful build, list all your images and you should the image that you just created:

now we need to create a container from this image, to do this we simply run

but in our case, since we need to expose the port 80 we need to add an additional line:

Now you should be able to see your running container:

to stop your container:

to list all your containers and the images they are spun from:

if you make changes to your project, you need to build it and create another image, which might be time-consuming. To avoid this, you can share directories which are called volume:

which in my case:

Now any changes to src directory in your docker project will be seen immediately in the corresponding image file and consequently in the running container.

to get into a Docker container:

to remove a container:

to remove an image:

if you have a container which has been spun from an image, you need to delete it before removing an image or you can use force option:

to list dangling images:

to remove dangling images: