Starting Traefik

The three services of the stack will be configured in the same configuration file, named docker-compose.yml. The first service to configure is Traefik. The first part with the definition of the reverse proxy is the following one:

version: '3'

services:
reverse-proxy:
image: traefik
command: --api --docker
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock

The version number identifies the version of the configuration file specifications. Then, the services section contains the definition of all containers. For now, there is only one container named reverse-proxy. The content of this section is the actual specification of the container.

The image parameter is the name of the image to use. If the image is not available locally, then it is downloaded from the Docker hub.

The command parameter overrides the default command of the image. In this configuration, Traefik is started with its web interface enabled, and it listens to Docker events.

The ports parameter indicates the port bindings to use between the container and the host. Here, port 80 is used for the reverse-proxy feature, and port 8080 exposes the web interface.

Finally, the volumes parameter defines the volume bindings to use. The binding defined here is the Docker socket. This allows Traefik to connect on the Docker bus to communicate with other containers that will register to the load balancer later.

Traefik can be started with the following command:

$ docker-compose up -d reverse-proxy

Once started, a new Docker instance should be running:

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
65cbfc50c551 traefik "/traefik --api --do…" 11 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp audio-encode-server-1_reverse-proxy_1
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.251.128