Docker: installation and concrete use on Ubuntu

Docker: a few useful information before …

Before embarking on our deployment of containers (Gitlab and Discourse) here is some information (a little loose) to know about containers.

The network

This is what is a little confusing initially when you think about virtualization, by default the containers are not directly exposed to an IP in your LAN, it uses a NAT / PAT system to advertise the services.

It is indeed possible to have several containers using Web servers, for example we can have an Nginx and Apache2 container, but the two containers will not be able to expose port 80 for example.

This is why, as a prerequisite, we installed Nginx as a reverse proxy.

It is possible to expose a container with “its own IP” through a bridge.

More information : Networking overview | Docker Documentation

A container is persistent but be careful

The storage of a container is persistent, that is to say that the modifications are written in the image of the container, but be careful, during a rebuild of the image, update, the data will be lost .

You can stop a container without the risk of losing data.

To overcome this reconstruction / update problem, it is possible to redirect folders from the container to a folder on the host server

If we take, for example, an Apache2 container, we will redirect the / var / www folder of the container to a folder located on the host, if this has two advantages:

  • To be able to access the folders and files of the web server that we publish
  • Update the container without losing data.

Where to find images

All Docker images are available here : Docker Hub

The hub being open to everyone, pay attention to the choice of images and preferably choose the Official images which are marked with a ribbon.

The latest tag

As we can see in the screenshot below, for the same image, there are several tags, often this corresponds to the version of the software that we want.

As we can see the latest tag points to version 10.5 of MariaDB.

I guess you understand what the latest tag is for, it points to the most recent stable version.

In certain situations, you should be wary of this tag, especially when you use several containers to run an application.

Let’s assume, that I want to run a web application, which needs Apache2, PHP and MariaDB 10.5

At the time of writing the tutorial, I can use the latest tag on my MariaDB container because it is on version 10.5.

After 6 months, I want to change the server and I start installing containers, my application must work with MariaDB 10.5, but since the latest tag is ported to 10.6, so my application will not work.

All that to say to be careful with Tag, for applications packaged in container like Gitlab or Discourse, the use of the latest tag allows us on the other hand to keep our application up to date.

Remember to check the versions behind latest.




Leave a Comment