Traefik is a reverse proxy and load balancer for web applications. Traefik is is an open-source project available under the MIT license.
This tutorial explains how to install Traefik inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Prepare environment
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
Install Traefik
- Host network
Run the following command to create a container for Traefik that uses host network:
docker run -d --name=traefik --restart=always --network=host \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik \
--api.insecure=true --providers.docker
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Traefik service is listening for HTTP connections on port 80. The dashboard is available on port 8080. Both ports can be changed with -p
option.
docker network create app-net
docker run -d --name=traefik --restart=always --network=app-net \
-p 8081:80 -p 8082:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik \
--api.insecure=true --providers.docker
Testing Traefik
To access the Traefik dashboard, open a web browser and go to http://<IP_ADDRESS>:8080
, where <IP_ADDRESS>
is the IP address of the system.
Uninstall Traefik
To completely remove Traefik, remove its container:
docker rm --force traefik
Remove Traefik image:
docker rmi traefik
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply