tailscale / tailscale/tailscale

Magic DNS not working in Docker container on Ubuntu 22.04 host

Open
#10,216 8 comments 0 reactions 0 assignees View on GitHub
bug containers needs-triage OS-linux
Dominant language
Go
Stars
36.5k
Forks
3.2k
Avg merge
2d 3h
Merged PRs (30d)
123

Description

### What is the issue?

**Expected Behavior:**
The hostname pi-1 should resolve to its Tailscale IP, and ping should succeed just like tailscale ping.

**Actual Behavior:**
Direct ping fails with a temporary failure in name resolution, despite tailscale ping working correctly.

### Steps to reproduce

**Tailscale Startup Command:**
```
docker run -d \
--name tailscale \
--hostname pi-1 \
--security-opt apparmor:unconfined \
-v /opt/tailscale/data:/var/lib/tailscale \
-v /dev/net/tun:/dev/net/tun \
-v /var/run/dbus:/var/run/dbus \
--network host \
--privileged \
--cap-add=NET_ADMIN \
--cap-add=NET_RAW \
-e TS_USERSPACE=0 \
--env TS_STATE_DIR=/var/lib/tailscale \
--env TS_ACCEPT_DNS=true \
--env 'TS_EXTRA_ARGS=--accept-dns=true --login-server=xxx --netfilter-mode=on' \
--env TS_AUTHKEY=xxx \
tailscale/tailscale
```

**Steps to Reproduce:**
Successful ping using Tailscale:
```
root@VM-0-15-ubuntu:/etc# docker exec tailscale tailscale --socket /tmp/tailscaled.sock ping -c 4 pi-1
fd7a:115c:a1e0::1 is local Tailscale IP
```

**Failed ping using the system's ping command:**
```
root@VM-0-15-ubuntu:/etc# ping -c 4 pi-1
ping: pi-1: Temporary failure in name resolution
```

**resolvectl status output for tailscale0 interface:**
```
Link 19 (tailscale0)
Current Scopes: none
Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
```

**tailscale logs**
```
root@VM-0-15-ubuntu:/etc# docker logs tailscale
boot: 2023/11/12 16:15:26 Starting tailscaled
boot: 2023/11/12 16:15:26 Waiting for tailscaled socket
2023/11/12 16:15:26 logtail started
2023/11/12 16:15:26 Program starting: v1.52.0-t31e1690f3, Go 1.21.3: []string{"tailscaled", "--socket=/tmp/tailscaled.sock", "--statedir=/var/lib/tailscale"}
2023/11/12 16:15:26 LogID: e0bfd1d42cd0c373a475dd8e1e7611a7f3c5b6758940d0de454ee9d490001989
2023/11/12 16:15:26 logpolicy: using system state directory "/var/lib/tailscale"
logpolicy.ConfigFromFile /var/lib/tailscale/tailscaled.log.conf: open /var/lib/tailscale/tailscaled.log.conf: no such file or directory
logpolicy.Config.Validate for /var/lib/tailscale/tailscaled.log.conf: config is nil
2023/11/12 16:15:26 wgengine.NewUserspaceEngine(tun "tailscale0") ...
2023/11/12 16:15:26 router: default choosing iptables
2023/11/12 16:15:26 router: v6nat = true
2023/11/12 16:15:26 dns: [resolved-ping=yes rc=resolved resolved=file nm=yes nm-resolved=yes nm-safe=no resolv-conf-mode=stub ret=systemd-resolved]
2023/11/12 16:15:26 dns: using "systemd-resolved" mode
2023/11/12 16:15:26 dns: using *dns.resolvedManager
2023/11/12 16:15:26 link state: interfaces.State{defaultRoute=eth0 ifs={br-bef9091898d3:[172.19.0.1/16 llu6] docker0:[172.18.0.1/16 llu6] eth0:[172.17.0.15/20 llu6]} v4=true v6=false}
2023/11/12 16:15:26 magicsock: disco key = d:39f8f95895a18059
2023/11/12 16:15:26 Creating WireGuard device...
2023/11/12 16:15:26 Bringing WireGuard device up...
2023/11/12 16:15:26 Bringing router up...
2023/11/12 16:15:26 external route: up
2023/11/12 16:15:26 Clearing router settings...
2023/11/12 16:15:26 Starting network monitor...
2023/11/12 16:15:26 Engine created.
2023/11/12 16:15:26 monitor: ip rule deleted: {Family:2 DstLength:0 SrcLength:0 Tos:0 Table:254 Protocol:0 Scope:0 Type:1 Flags:0 Attributes:{Dst: Src: Gateway: OutIface:0 Priority:5210 Table:254 Mark:16711680 Pref: Expires: Metrics: Multipath:[]}}
2023/11/12 16:15:26 monitor: ip rule deleted: {Family:2 DstLength:0 SrcLength:0 Tos:0 Table:253 Protocol:0 Scope:0 Type:1 Flags:0 Attributes:{Dst: Src: Gateway: OutIface:0 Priority:5230 Table:253 Mark:16711680 Pref: Expires: Metrics: Multipath:[]}}
2023/11/12 16:15:26 monitor: ip rule deleted: {Family:2 DstLength:0 SrcLength:0 Tos:0 Table:0 Protocol:0 Scope:0 Type:7 Flags:0 Attributes:{Dst: Src: Gateway: OutIface:0 Priority:5250 Table:0 Mark:16711680 Pref: Expires: Metrics: Multipath:[]}}
2023/11/12 16:15:26 monitor: ip rule deleted: {Family:2 DstLength:0 SrcLength:0 Tos:0 Table:52 Protocol:0 Scope:0 Type:1 Flags:0 Attributes:{Dst: Src: Gateway: OutIface:0 Priority:5270 Table:52 Mark:0 Pref: Expires: Metrics: Multipath:[]}}
2023/11/12 16:15:26 pm: migrating "_daemon" profile to new format
2023/11/12 16:15:26 logpolicy: using system state directory "/var/lib/tailscale"
2023/11/12 16:15:26 got LocalBackend in 45ms
2023/11/12 16:15:26 Start
2023/11/12 16:15:26 Backend: logs: be:e0bfd1d42cd0c373a475dd8e1e7611a7f3c5b6758940d0de454ee9d490001989 fe:
2023/11/12 16:15:26 Switching ipn state NoState -> NeedsLogin (WantRunning=false, nm=false)
2023/11/12 16:15:26 blockEngineUpdates(true)
2023/11/12 16:15:26 health("overall"): error: state=NeedsLogin, wantRunning=false
2023/11/12 16:15:26 wgengine: Reconfig: configuring userspace WireGuard config (with 0/0 peers)
2023/11/12 16:15:26 wgengine: Reconfig: configuring router
2023/11/12 16:15:26 wgengine: Reconfig: configuring DNS
2023/11/12 16:15:26 dns: Set: {DefaultResolvers:[] Routes:{} SearchDomains:[] Hosts:0}
2023/11/12 16:15:26 dns: Resolvercfg: {Routes:{} Hosts:0 LocalDomains:[]}
2023/11/12 16:15:26 dns: OScfg: {}
boot: 2023/11/12 16:15:26 Running 'tailscale up'
2023/11/12 16:15:26 Start
2023/11/12 16:15:26 generating new machine key
2023/11/12 16:15:26 machine key written to store
2023/11/12 16:15:26 control: client.Shutdown()
2023/11/12 16:15:26 control: client.Shutdown
2023/11/12 16:15:26 control: authRoutine: exiting
2023/11/12 16:15:26 control: updateRoutine: exiting
2023/11/12 16:15:26 control: mapRoutine: exiting
2023/11/12 16:15:26 control: Client.Shutdown done.
2023/11/12 16:15:26 Backend: logs: be:e0bfd1d42cd0c373a475dd8e1e7611a7f3c5b6758940d0de454ee9d490001989 fe:
2023/11/12 16:15:26 Switching ipn state NoState -> NeedsLogin (WantRunning=true, nm=false)
2023/11/12 16:15:26 blockEngineUpdates(true)
2023/11/12 16:15:26 StartLoginInteractive: url=false
2023/11/12 16:15:26 control: client.Login(false, 2)
2023/11/12 16:15:26 control: LoginInteractive -> regen=true
2023/11/12 16:15:26 control: doLogin(regen=true, hasUrl=false)
2023/11/12 16:15:26 control: control server key from https://wireguard.52xiuyixiu.com: ts2021=[i2fPh], legacy=[GyYHE]
2023/11/12 16:15:26 control: Generating a new nodekey.
2023/11/12 16:15:26 control: RegisterReq: onode= node=[GCTm5] fup=false nks=false
2023/11/12 16:15:26 control: RegisterReq: got response; nodeKeyExpired=false, machineAuthorized=true; authURL=false
2023/11/12 16:15:26 blockEngineUpdates(false)
2023/11/12 16:15:26 active login: test
2023/11/12 16:15:26 monitor: gateway and self IP changed: gw=172.17.0.1 self=172.17.0.15
2023/11/12 16:15:26 Switching ipn state NeedsLogin -> Starting (WantRunning=true, nm=true)
2023/11/12 16:15:26 magicsock: SetPrivateKey called (init)
2023/11/12 16:15:26 wgengine: Reconfig: configuring userspace WireGuard config (with 0/0 peers)
2023/11/12 16:15:26 wgengine: Reconfig: configuring router
2023/11/12 16:15:26 peerapi: serving on http://[fd7a:115c:a1e0::1]:59780
2023/11/12 16:15:26 peerapi: serving on http://100.64.0.1:58436
2023/11/12 16:15:26 health("router"): error: setting up filter/ts-input: running [/sbin/ip6tables -t filter -N ts-input --wait]: exit status 3: modprobe: can't change directory to '/lib/modules': No such file or directory
ip6tables v1.8.8 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
2023/11/12 16:15:26 router: somebody (likely systemd-networkd) deleted ip rules; restoring Tailscale's
2023/11/12 16:15:26 magicsock: home is now derp-3 (sin)
2023/11/12 16:15:26 magicsock: adding connection to derp-3 for home-keep-alive
2023/11/12 16:15:26 magicsock: 1 active derp conns: derp-3=cr0s,wr0s
2023/11/12 16:15:26 Switching ipn state Starting -> Running (WantRunning=true, nm=true)
2023/11/12 16:15:26 derphttp.Client.Connect: connecting to derp-3 (sin)
2023/11/12 16:15:26 control: NetInfo: NetInfo{varies=false hairpin=false ipv6=false ipv6os=true udp=true icmpv4=false derp=#3 portmap= link="" firewallmode="ipt-default"}
2023/11/12 16:15:26 magicsock: endpoints changed: 150.158.12.202:54434 (stun), 172.17.0.15:54434 (local), 172.18.0.1:54434 (local), 172.19.0.1:54434 (local)
boot: 2023/11/12 16:15:26 Startup complete, waiting for shutdown signal
2023/11/12 16:15:29 magicsock: derp-3 connected; connGen=1
```

### Are there any recent changes that introduced the issue?

_No response_

### OS

Linux

### OS version

Ubuntu 22.04

### Tailscale version

1.52.0

### Other software

_No response_

### Bug report

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.