Traefik

Next is the reverse proxy, Traefik. The proxy builds its routing rules from labels when containers are created, so it needs to connect to the Docker API:

reverse-proxy:
image: sixeyed/traefik:v1.7.8-windowsservercore-ltsc2019
command: --docker --docker.endpoint=npipe:////./pipe/docker_engine --api
ports:
-
"80:80"
- "8080:8080"
volumes:
- type: npipe
source: \.pipedocker_engine
target: \.pipedocker_engine
networks:
- nd-net

The Traefik container publishes to port 80 on the host, connects to the application network, and uses a volume for the Docker API-named pipe. These are the same options that I used when I started Traefik using docker container run; typically, you can just copy your run commands into your Docker Compose file.

Port publishing is the same in Docker Compose as it is when running a container. You specify which container port to publish and which host port it should publish to, so Docker routes incoming host traffic to the container. The ports section allows multiple mappings, and you can optionally specify TCP or UDP protocols if you have a specific requirement.

I'm also publishing port 8080 and using the --api flag in the Traefik configuration. This gives me access to Traefik's dashboard, where I can see all the routing rules Traefik has configured. This is useful in non-production environments, to check your proxy rules are correct, but this is not something you want exposed publicly in production.

Docker Compose also supports extended definitions, which I'm using for the volume specification. Rather than using a single line to define the volume mount, I've split out the type of the volume, the source, and the target into different lines. This is optional, but it makes the file easier to read.

..................Content has been hidden....................

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