Multi-registry cache for Docker/containerd, optimizing image pulls using the original registry image
8.2K
For more up-to-date informations, check the Github repositoryā
This project automates the process of connecting the Traefik reverse proxy to Docker container networks dynamically. It listens for Docker events and manages Traefik's network connections to ensure it can reverse proxy for containers labeled for Traefik management.
This is useful if you have, for example, one traefik proxy which handle incoming requests for multiple docker compose services. It will only to the needed networks (ie the one whith traefik labels) without the need of a common traefik network for all services, which break the isolation principal.
If you want to run it outside containers, make sure you have the following installed:
requirements.txt for details.Start the container :
docker run -d \
--name traefik_network_connector \
-v $PWD/config.yaml:/usr/src/app/config.yaml \
-v /var/run/docker.sock:/var/run/docker.sock \
obeoneorg/traefik_network_connector:latest
And it's ok !
For more details about the configuration options, refer to the Configurationā section.
Modify config.yaml to adjust the Traefik container name, the label to monitor, and other settings. Key configuration options include:
traefik.containerName: Name of the Traefik container in Docker.logLevel: Adjust the verbosity of the script's output.traefik.monitoredLabel: Docker label that triggers network connection actions. (DEPRECATED ! Directly use traefik.docker.network instead in Traefik 2.0+):warning: Take care ! @ If you use
traefik.monitoredLabel, you just have to give the network name in your compose file. But if you usetraefik.docker.network, you need to prefix the network name (for the example, let's saymynetwork) with your deployment name (for example, you rundocker compose upin a directory namedfoo, your network name will befoo_mynetwork). I don't understand why me, a single developer without special knowledge about docker, I was able to detect the compose name, but not Traefik... So you can't use a same compose for multiple deployment, it's kind of ridiculous, but I didn't find an elegant solution... (Il you have an idea, contact me !)
For a detailed explanation of all configuration options, refer to the comments within config.yaml.
To override the default configuration settings, use the command line arguments using the --key=value (key is the YAML path) format. The YAML path is used to access the corresponding value in the configuration. For example, to override the log level, use the --loglevel=INFO argument. For the docker host, use the --docker.host argument.
List of available command line arguments can be found using --help, and explaination in the config.yaml file.
To override the default configuration settings, you can also use the environment variables (as for command line arguments above, key is the YAML path but using _ instead of .). For example, to override the docker host, use the DOCKER_HOST environment variable.
To get started with the Traefik Network Connector, follow these steps:
Clone the repository:
git clone https://github.com/obeone/traefik_network_connector.git
Navigate to the cloned directory:
cd traefik_network_connector
Install the required dependencies:
pip install -r requirements.txt
To use the Traefik Automatic Docker Network Connector, follow these steps:
Ensure Docker is running and you have the necessary permissions to interact with Docker's API.
Configure settings the way you likeā .
Run the script:
python main.py --config=<path_to_your_config.yaml>
If the --config argument is omitted, the script defaults to using config.yaml in the current directory.
To manage the Traefik Automatic Docker Network Connector as a service using systemd, follow these steps:
traefik_network_connector.service file in /etc/systemd/system/.sudo systemctl daemon-reload.sudo systemctl start traefik_network_connector.sudo systemctl enable traefik_network_connector.sudo systemctl status traefik_network_connector.autoproxy.networks) only these networks will be connected to.To ensure secure communication with the Docker server, configure the following TLS settings in config.yaml:
docker:
host: "tcp://<your_docker_host>:2376" # Replace with your Docker host and port
tls:
verify: "/path/to/ca.pem" # Path to CA certificate for TLS verification
cert: "/path/to/cert.pem" # Path to client certificate for TLS
key: "/path/to/key.pem" # Path to client key for TLS
This section addresses common issues and questions:
Q: How do I resolve Docker API communication errors?
config.yaml (or CLI/Environment variable) TLS settings are correct.Q: What if Traefik is not connecting to a container's network?
Q: How can I debug connection issues between Traefik and Docker containers?
logLevelto DEBUG to get more detailed output from the script. This can provide insights into the connection process and where it might be failing.Q: How do I override configuration settings?
config.yaml can be overridden by an equivalent command line argument or environment variable, see Configuration Settingsā .Q: What is the priority for configuration settings?
config.yaml.Q: How can I debug issues with incorrect configuration values?
--help option with the script to see available command line arguments.Q: How can I specify the networks Traefik should connect to?
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests. Before contributing, please read through existing issues and pull requests to ensure that your contribution is unique and beneficial.
For support or queries, please open an issue on this repository. We aim to respond as quickly as possible to all inquiries.
š¾ obeone
Primarily powered by my new brain, GPT-4o, with some crucial tweaks and oversight from my secondary brain.
Check out more of my work on GitHubā .
Content type
Image
Digest
sha256:b203e275fā¦
Size
267 Bytes
Last updated
25 days ago
docker pull obeoneorg/traefik_network_connector:sha256-778a8ef72f5f3d49c3e2b6347c7f6ed2dfce26282b0701285dcf56579355d497.sig