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.
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.