Skip to content

Update reverse proxy networks

Maksym Zaporozhets edited this page Jan 8, 2024 · 2 revisions

maintenance:traefik:update-networks

Connect/disconnect Traefik proxy to/from Docker networks.

Description

This command is designed for MacOS and/or other systems where Traefik proxy cannot use the host network mode. Note that command is not compatible with the Traefik configuration providers.docker.exposedbydefault=true - it handles only container that have the label traefik.enable=true.

Not tested with Docker Desktop on Linux (who uses that?).

Usage

One-time connect/disconnect Traefik proxy to/from Docker networks:

php "${DOCKERIZER_PROJECTS_ROOT_DIR}dockerizer_for_php/bin/dockerizer" -d xdebug.start_with_request=trigger maintenance:traefik:update-networks -c reverse-proxy

Continuous connect/disconnect Traefik proxy to/from Docker networks and watch for Docker network events (note the --watch option):

php "${DOCKERIZER_PROJECTS_ROOT_DIR}dockerizer_for_php/bin/dockerizer" -d xdebug.start_with_request=trigger maintenance:traefik:update-networks -c reverse-proxy --watch

Use the -vvv for verbose output in the debug mode to view all events data that Dockerizer receives from the Docker daemon.

Restart the Traefik proxy requires restarting this command as well.

Command options

  • -c (--container, required): Container name or ID of the Traefik proxy.
  • -w (--watch, optional): Watch for Docker network events and connect/disconnect Traefik proxy to/from new compositions automatically.
  • -vvv (--verbose, optional): Symfony verbose output for debugging purposes.

How it works

This is a stateful command collects information about all Docker networks and Traefik proxy container. We store the state in order to react the container kill and network connect events fast and without iterating through all compositions/containers/networks/etc.

This command will:

  • Collect information about all Docker networks and containers with the label traefik.enable=true.
  • Connects Traefik proxy to all networks that have containers with the label traefik.enable=true.
  • Disconnects Traefik proxy from all networks that do not have containers with the label traefik.enable=true.
  • Watch for Docker network connect events and container kill/die events and react to them.

Clone this wiki locally