This is not a complete article - it’s a post with docker essential tips which you have to know if you want to run some of your apps within a docker enviroment. I’m going to update this article when I learn this system better. These are my first steps and I’ll use my article as a reminder in the future.

Docker installation

Docker still dosn’t have full support in mac os. Of course they have [Boot2Docker][2], but it’s docker lauched within a VM. So, I prefer to use my own VM running in VirtualBox on another machine. In order to do so, I use ubuntu. Installation on ubuntu linux looks as follows:

$ wget -qO- https://get.docker.com/ | sh

or you can use ubuntu repository:

$ sudo apt-get install docker.io

If you see an error like this:

FATA[0000] Post http:///var/run/docker.sock/v1.17/images/create?fromImage=mongo%3Alatest: dial unix /var/run/docker.sock: no such file or directory

you just need to reboot a server.

Build your own container

To build you own container, you need to have Dockerfile. Go to the folder where your docker file is located. And execute this command:

$ sudo docker build -t [name] .

Useful parameters:

  • -no-cache - builds container avoiding cached steps.

Run container

After a container building process, you can launch it. The command could be like this:

$ sudo docker run -it -p 8080:8080 --link my-mongo:mongo [name]

Useful parameters:

  • -d - runs container in the background
  • -p [container port]:[host port] - opens the exposed port on an host machine
  • --link [name or id]:[alias] - allows a container to access another container speicified by [name or id]
  • -v [host path]:[container path] - for external volume linking
  • --restart="always" - restarts your container after a failure or a system reboot

UPD: May 25, 2015