Vote

Docker is an open source software allowing to facilitate the deployment of isolated applications in software containers to be operated in various environments. Docker is a tool often used in development environments in order to solve integration issues (CI) and continuous deployment (CD).

Presentation

Unlike virtual machines relying on a physical infrastructure, Docker affords to mutualize the physical layer and the operating system layer by wrapping the application and its dependencies (libraries, configuration files …). Advantages : only one OS to administrate, all containers are isolated.

Here are pictures of the difference between Container and VM:

A public register maintained by an active community allows Docker to make available containers ready to be quickly operated.

Docker is based on LXC (Linux Containers) and includes the following elements :

Functionality of the Linux kernel to limit, count and isolate resources (CPU, RAM, etc.) used by a process group.

Advanced management of permissions both at the applications’ level and the files system level.

Functionality of the Linux kernel allowing isolation, in order to ensure that a container can not affect another.

Functionality allowing to change a process root, in order to isolate it in a system as a security measure.

Docker provides services to simply perform différent actions: create, edit, publish and operate containers. You often hear about containers, images and DockerFile :

Source file containing instructions, elements to install, it is a configuration file.

Compilation of a DockerFile file to create a portable image, ready to be deployed

Execution of an image, container loading of an image


Installation

In order to install Docker on Debian 8, you only need to go through the management tool for packages :

On Debian 7, it is essentiel to add the source deb http://http.debian.net/debian wheezy-backports main in the file sources.list.
Then we can operate the following commands tu update our source list, install wheezy-backports :

Install Docker thanks to the following command for script execution :

Once Dock installed, you just have to launch the service :


Creation of a container

In this example, we will install a container Nginx from the images available in the Docker warehouses :

Please think about directing your choice between the description, the popularity and whether it is an official container or not.
We are going to repatriate the official Nginx container image :

We check our image list:

We can see that it was successfully repatriated :

We install the container :

We check how well the container is installed :

This way, you can see your container operated (below is the detail of the command docker ps) then we start our container :

By default, Docker uses NAT to match input ports on the server returned to listening ports of different containers with the option -p :

The host port matches the port on which you have to contact the host to have access to the service, the container port matches the port to which the request will be redirected at the container’s level.
We are going to create a second container by adding this argument :

You are aware of the service as being active by opening your web browser on http://IP_HOTE:1234


DockerFile

You can create your own container from a configuration file appointed DockerFile.
We are going to create a Debian container and install a server Apache2 accessible from outside.
Here is the DockerFile file’s content

Now we can create our container from the Dockerfile with this command :

We install our container by mapping the port 555 of the host towards the port http of the container :

From now on, you can check the apache server access from this URL : http://IP_HOTE:5555


Useful commands

The following command can display the running containers list :

Container’s identifier

Personal identifier of the container’s image.

Command placed as parameter when the container was created

Date of creation of the container.

Container state.

The different redirections of configured ports.

Random name given to the container, this is customizable thanks to the option -name during the execution docker run.

Here are some useful commands :

You can find all the docker images on https://hub.docker.com/explore/

You can find all the commands linked to docker in the assistance service :

Categories: DevOpsTutorials

Related Posts

System

Installation of a web server LEMP (Linux, Nginx, MySQL, PHP)

Vote The installation of a server LEMP Linux + Nginx + MySQL + PHP might be more useful and efficient than an Apache (server LAMP). Articles similaires

System

Operating load-balancing with HAproxy

Vote HAproxy is a software allowing Load-Balancing between several web servers by allocating requests in an almost transparent way for the user. Articles similaires

System

10 tips to write efficient scripts on Linux

Vote The shell script is the most simple type of programming you would write on Linux. Moreover, it is a necessary skill to automate your system administration tasks, to develop new simple features, … In Read more…