Gluetun Not Found: TUN Device in Docker
While working with Docker and Gluetun yesterday, the underlying hardware was restarted and the Gluetun container stopped working. Upon investigation, the following error was found in the docker-compose.yml file:
version: "3.8"
services:
gluetun:
image: qmcgaw/gluetun
container_name: gluetun
restart: always
networks:
- vpn
ports:
- "53:53/udp"
- "53:53/tcp"
- "1701:1701/udp"
- "1719:1719/udp"
- "1723:1723/tcp"
- "4500:4500/udp"
- "500:500/udp"
- "443:443/tcp"
environment:
- OPENVPN_CONFIG=germany-tcp
volumes:
- /etc/wireguard:/etc/wireguard
- /var/run/gluetun:/var/run/gluetun
- ./gluetun.yml:/app/gluetun.yml
- ./openvpn:/app/openvpn
cap_add:
- net_admin
Understanding Gluetun and TUN Devices
Gluetun is a lightweight OpenVPN and WireGuard VPN client for Docker. It allows users to easily set up a VPN connection without having to install a VPN client on the host machine. Instead, the VPN connection is established within a Docker container. Gluetun uses a TUN (tap-to-untap) device, which is a virtual network interface that allows the Docker container to connect to the VPN server.
Debugging the Error
The error message suggests that the TUN device could not be found within the Docker container. This can be caused by a variety of issues, including:
- Network configuration issues
- Docker daemon configuration issues
- Missing dependencies within the Docker container
Resolving the Issue
To resolve the issue, first check the Docker daemon logs for any errors related to network configuration or TUN device creation. If there are no errors, check that the necessary dependencies are installed within the Docker container. Specifically, make sure that the iproute2 package is installed, as it includes the necessary utilities for creating TUN devices.
If the issue persists, try creating a new Docker network and attaching the Gluetun container to it. This will ensure that the TUN device is created within the correct network namespace.
Additional Resources
- GitHub repository
- Docker documentation