Pages

Friday, August 7, 2015

First steps on Docker

Docker is a new way to "virtualize" applications.

Before Docker, to run multiple applications on the same host, we can install all the applications on the host (no virtualization), or put each application on a virtual machine (virtualized application).
On the first hand, because all the applications are running on the host, we may have to isolate each application to the others using chrooting. If the host fails, all the running applications are unavailable. But all the physical ressources are used by the host and the applications. 
On the other hand, each application is running on a separate virtual machine. For this reason, it requires more physical ressources (for each application, one virtual OS is running). But each application is isolated to the others, and if the host running the application fails, the others are still running (by "host", I mean the virtual machine running the application. It is obvious that if the host server fails, all the VMs will fail)

With Docker, the things are a bit different. Each application is in a Docker "container".  And Docker acts as a virtual machine on which all those containers run. Each container is isolated to the others unless links are made between containers or from the container to the host machine. The ratio of the ressources available for applications to the ressources used by the OS is better here than using virtual machines. And as virtual machine, when we need to remove the application and keep the whole system clean, it is as simple as a virtual machine : remove and delete the container.
Another interesting thing about Docker : versioning. It is possible to run an application using a specific configuration. For example, you have a web application which require tomcat server, when you are doing your container for this application, you can choose between using the latest version of Tomcat, or a specific one (version 6, 7 or 8) using a tag while loading the image.

Imagine a networking tool using Docker containers, based on different manufacturer OS dockerized images.

So now, about how to use Docker?

Just download it from docker.io and install it on your system.
By the way, if you have any error messages on Linux systems, ensure docker service is started and run the docker commands using sudo or with as a member of docker group. And if you still have error messages, delete the file in docker folder and restart the service.

If the install is working, you should be able to run your first docker container based on the hello-world image : docker run hello-world

So the commands to play with your containers:

  • docker run
    • To launch a container in background (as a daemon) or in interactive mode
  • docker build
    • To build a docker image, by reading instructions from a Dockerfile (puppet/chef style)
  • docker stop
    • To stop a running container
  • docker rm
    • To delete the container



No comments: