tailscale / tailscale/tailscale
Docker compose networking breaks with exit node enabled (Mullvad)
- Dominant language
- Go
- Stars
- 36.5k
- Forks
- 3.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 123
Description
### What is the issue?
HI
I've setup an exit node using mullvad vpn, as follows
```bash
exit_node_ip=100.81.35.38
sudo tailscale up \
--accept-routes \
--exit-node="${exit_node_ip}" \
--exit-node-allow-lan-access=true \
--ssh
```
Tailscale is running directly in Ubuntu 22.04, not under docker.
And thats working fine
I have a subnet router on another server thats hosting a few services
When deploying anything with docker compose on the exit node box, I have to set the network_mode as either `bridged` or `host`
I cannot let it create a network, as it won't let me access any of the incoming subnet cidrs from the subnet router.
If I set to either of those network modes, so it uses the existing docker networks i can access the routes
However - what I cannot access is containers within the same compose file via their hostname, as it seems to try to resolve them using magic dns instead of the internal docker resolver.
if I define a new network in the compose file, or completely leave off network_mode, and let compose just spawn a network matching the dompose file directory, then the containers get no internet access at all.
You can see here, promtail cannot reach loki
```bash
promtail-1 | level=warn ts=2024-03-03T01:43:17.518118904Z caller=client.go:419 component=client host=loki:3100 msg="error sending batch, will retry" status=-1 tenant=test error="Post \"http://loki:3100/loki/api/v1/push\": dial tcp: lookup loki on 127.0.0.53:53: server misbehaving"
```
```yml
version: '3.8'
name: test-metrics
services:
prometheus:
image: prom/prometheus:v2.20.1
volumes:
- ./config/prometheus/config.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- "9090:9090"
network_mode: host
grafana:
image: grafana/grafana:latest
volumes:
- ./config/grafana/datasources:/etc/grafana/provisioning/datasources
- ./config/grafana/dashboards/dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml
- ./config/grafana/dashboards/logs.json:/var/lib/grafana/dashboards/logs.json
- grafana-data:/var/lib/grafana
ports:
- "3000:3000"
environment:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin_password
depends_on:
- prometheus
network_mode: host
postgres-exporter:
image: prometheuscommunity/postgres-exporter
env_file:
- .env
environment:
DATA_SOURCE_NAME: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable"
network_mode: host
promtail:
image: grafana/promtail:2.9.4
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock
- ./config/promtail/config.yml:/etc/promtail/config.yml
command: -config.file=/etc/promtail/config.yml
depends_on:
- prometheus
- loki
network_mode: host
loki:
image: grafana/loki:2.9.4
command: -config.file=/etc/loki/local-config.yml
depends_on:
- prometheus
- grafana
volumes:
- loki-data:/loki
- ./config/loki/config.yml:/etc/loki/local-config.yml
network_mode: host
volumes:
loki-data:
grafana-data:
```
Like I said - if I don't have those `network_mode: host` entries, then postgres-exporter cant hit the postgres instance running on the remote (tailnet) subnet.
If I disable the exit node vpn, the internal docker routing works.
### Steps to reproduce
_No response_
### Are there any recent changes that introduced the issue?
_No response_
### OS
Linux
### OS version
_No response_
### Tailscale version
_No response_
### Other software
_No response_
### Bug report
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.