Connect to gluetun and another service not using gluetun in same compose? #492
-
Say I have 3 services named: version: '3.8'
services:
postgres:
image: postgres
container_name: postgres
restart: always
ports:
- 5432:5432
gluetun:
image: qmcgaw/gluetun
container_name: gluetun
cap_add:
- NET_ADMIN
network_mode: bridge
ports:
- 8888:8888/tcp # HTTP proxy
- 8388:8388/tcp # Shadowsocks
- 8388:8388/udp # Shadowsocks
- 8000:8000/tcp # Built-in HTTP control server
- "5000:5000" # for html-monitor-api
volumes:
- ./glueten:/gluetun
environment:
VPNSP: ${VPNSP}
TZ: ${TZ}
OPENVPN_USER: ${OPENVPN_USER}
OPENVPN_PASSWORD: ${OPENVPN_PASSWORD}
restart: always
html-monitor-api:
image: python:3.8
container_name: html-monitor-api
network_mode: "service:gluetun"
entrypoint: /html-monitor/entrypoint.sh
restart: always
environment:
DATABASE_URI: ${DATABASE_URI}
volumes:
- ./html-monitor:/html-monitor I would like the following behavior from the
Before adding Now, however I get the following error: I do not know much about docker networking. Is there a way I can have |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's because it uses Unbound with DNS over tls through the vpn. Unbound is not aware of the Docker hostnames such as postgres. You might want to subscribe to the issue #281 for that. It will eventually be resolved but don't expect it too soon either. You can disable DOT and use KEEP_NAMESERVER so gluetun uses the Docker DNS but then all your DNS requests will leak out of the VPN and in plaintext if you did not configure some dns server on your LAN (like github.com/qdm12/dns). The viable alternative is to set a fixed IP address to postgres using docker-compose and use IP address to connect to it for now. |
Beta Was this translation helpful? Give feedback.
It's because it uses Unbound with DNS over tls through the vpn. Unbound is not aware of the Docker hostnames such as postgres. You might want to subscribe to the issue #281 for that. It will eventually be resolved but don't expect it too soon either. You can disable DOT and use KEEP_NAMESERVER so gluetun uses the Docker DNS but then all your DNS requests will leak out of the VPN and in plaintext if you did not configure some dns server on your LAN (like github.com/qdm12/dns). The viable alternative is to set a fixed IP address to postgres using docker-compose and use IP address to connect to it for now.