A compilation for an ecosystem with docker
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Docker eco-system


Clone the repository under the /srv/ folder. In this way, this prevent to have a "no such file or directory" error when the server or the container reboot.

$ sudo git clone https://github.com/JAGFx/DockerConfiguration.git /srv/
$ sudo chown username:username -R /srv/DockerConfiguration

Docker installation

Follow the documentation at Official installation guides

You need to install docker-compose. Follow this link

Docker setting up

Init the swarm mode for the manager and worker node

$ docker swarm init --advertise-addr=

Replace the by the ip address of the current node

Proxy / revers proxy: Treafik

Treafik allow you to access to a container from domain without specify the port.

The current configuration are set with HTTPS connexion with Let's Encrypt.

To generate certificate, it's necessary to resolve the domain. See the Treafik provider to match with your domain provider and change all environment variable on docker-compose/traefik/docker-compose.yml

Setup Traefik

To match with your server configuration, you must change:

  • docker.domain: The base domain of your node
  • acme.email: Email used by Let's encrypt

Create a sharded network. Use it for all container and stack.

$ docker network create -d overlay tf_gate --internal --attachable

TODO Restrict access by port by default

Example to use docker-compose.yml:

version: '3.6'

    image: <YOUR_IMAGE>
      traefik.enable: "true"
      traefik.port: <CONTAINER_INTERNAL_PORT>
      traefik.frontend.rule: "Host:<YOUR_DOMAIN>"
      traefik.docker.network: "tf_gate"
      - tf_gate

    external: true
    name: tf_gate

After that, you can launch the Traefik stack !

$ cd docker-compose/traefik/
$ docker stack deploy -c docker-compose.yml traefik

Access to the Traefik dashboard at http://<YOUR_HOST>:8080

Container manager: Portainer

It's the first that i've found. It's simply, powerful and allow all actions that you can do with docker-cli. For more information, see the Portainer website

The original portainer-agent-stack.yml was picked up from tcoupin/swarm-playground

$ cd docker-compose/
$ docker stack deploy -c portainer-agent-stack.yml portainer

Image manager and repository manager: Gitlab

To my great surprise, Gitlab can manage the git repositories AND docker image. It's perfect, you can have only ONE app to do TWO different things :D !


I use a Omnibus configuration file (It's this one who are used in the Gitlab docker image)

To match with your server configuration, you must change:

  • gitlab_rails['gitlab_email_from']: Email used as sender of email from Gitlab
  • gitlab_rails['time_zone']: The timezone fo Gitlab instance
  • gitlab_rails['initial_root_password']: The password to init all necessary account
  • external_url: The external url to your Gitlab instance. Please keep EXACTLY the same as the traefik.lab.frontend.rule in docker-compose/gitlab/docker-compose.yml
  • registry_external_url: The external url to your Registry instance. Please keep EXACTLY the same as the traefik.registry.frontend.rule in docker-compose/gitlab/docker-compose.yml

Deploy a stack

$ cd docker-compose/gitlab/
$ docker stack deploy -c docker-compose.yml gitlab


To use a registry for you project image, you must enable this option on the repository settings.

Currently, you don't need to use the port. Traefik match directly to the internal container port.

I work to correct it :D !

Sample provide by Gitlab:

docker login gl-registry.jagfx.fr:4567
docker build --compress -t gl-registry.jagfx.fr:4567/jagfx/projecttest:latest .
docker push gl-registry.jagfx.fr:4567/jagfx/projecttest

You must use this following commands:

docker login gl-registry.jagfx.fr
docker build --compress -t gl-registry.jagfx.fr/jagfx/projecttest:latest .
docker push gl-registry.jagfx.fr/jagfx/projecttest

Deploy image from registry

When you finish to store you image on Gitlab registry, you can use it to deploy a container or a stack.

I recommend you to create a docker compose file. See at docker-compose/landing-compose.yml

See also Setup Traefik section to allow access of the container from outside.

When it's done, you can deploy it.

$ cd docker-compose/
$ docker stack deploy -c landing-compose.yml landing-page

-- OR --

$ cd docker-compose/
$ docker-compose -f landing-compose.yml -p landing-page up -d --force-recreate


If you need to have a database for your project(s), you can install MySQL server with PHPMyAdmin interface. You be able to manage many database from the PHPMyAdmin interface

Found the package at docker-compose/database

To connect in your mysql databases, you need to have:

  • Database host
  • Username (Default root)
  • Password (Default root. Change it at the first connexion)

Each mysql server has a docker-compose file: docker-compose/database/mysql-alpha-compose.yml

Note the mysql-alpha-compose.yml, this server has a name "mysql-alpha". This name will be used to name the docker file and the host. (I use the radio alphabet)

Change it in mysql docker file (Volume name, network name and network alias)

After that, you just add this name inside the PMA_HOSTS variables of PHPMyAdmin file : docker-compose/database/pma-compose.yml

Note: Use a comma to separate each host. You can use the defaults port for all host (3306 or 33060).

Note2: All mysql server are in private network. They are not accessible from the world


PMA_HOSTS: "mysql-alpha:33060,mysql-bravo:33060"

Youpi !!! Deploy your databases !!!

$ cd scirpts/
$ sh get-pma-metro-ui.sh

$ cd docker-compose/database/
$ docker-compose -f mysql-alpha-compose.yml up -d
$ docker stack deploy -c pma-compose.yml pma