I’m trying to create a vpn container that acts as a gateway for other container to use.
My docker-compose.yml is
version: '2' services: mullvad: container_name: <container_name> image: <vpn_server_image> command: sleep infinity volumes: - "./openvpn:/etc/openvpn" networks: vpn: ipv4_address: 172.20.0.1 devices: - "/dev/net/tun:/dev/net/tun" privileged: true cap_add: - NET_ADMIN networks: vpn: driver: bridge ipam: driver: default config: - subnet: 172.20.0.0/16 gateway 172.20.0.1
When I try to run the app I get an address already in use error:
# docker-compose up -d Recreating <container_name> ERROR: for <container_name> Address already in use Traceback (most recent call last): File "<string>", line 3, in <module> File "compose/cli/main.py", line 63, in main AttributeError: 'ProjectError' object has no attribute 'msg' docker-compose returned -1
network inspection suggests that the address shouldn’t be in use:
# docker network inspect <container_name>_vpn [ { "Name": "<container_name>_vpn", "Id": "<guid>", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.20.0.0/16", "Gateway": "172.20.0.1" } ] }, "Internal": false, "Containers": {}, "Options": {}, "Labels": {} } ]
What’s going on here?
In case I’m just doing it horribly wrong, what I want is a “vpn” network that other containers can attach to. When they do so, they are given a default route to the vpn container. This container will be configured to bridge the docker network to the vpn tunnel.