beringresearch / macpine

Lightweight Linux VMs on MacOS
https://beringresearch.github.io/macpine/
Apache License 2.0
898 stars 22 forks source link

Tailscale fails to run in LXD container #170

Closed nelfata closed 5 months ago

nelfata commented 8 months ago

When installing Tailscale inside an LXD container the

To Reproduce Steps to reproduce the behavior:

  1. alpine launch --image alpine_3.16.0_lxd --name lxd --port 8443 --ssh 2222 --mount $(pwd)
  2. lxc launch ubuntu:22.04 ubuntu
  3. lxc config set ubuntu security.privileged true
  4. Inside the container: apt-get update && sudo apt-get install tailscale

Expected behavior Tailscale should run and provide a URL to use in order to activate the connection.

Screenshots

root@ubuntu:~# tailscale up
failed to connect to local tailscaled; it doesn't appear to be running (sudo systemctl start tailscaled ?)
root@ubuntu:~# systemctl start tailscaled
root@ubuntu:~# tailscale up
failed to connect to local tailscaled; it doesn't appear to be running (sudo systemctl start tailscaled ?)
root@ubuntu:~# systemctl status tailscaled
× tailscaled.service - Tailscale node agent
     Loaded: loaded (/lib/systemd/system/tailscaled.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-12-30 00:51:00 UTC; 6s ago
       Docs: https://tailscale.com/kb/
    Process: 726 ExecStartPre=/usr/sbin/tailscaled --cleanup (code=exited, status=0/SUCCESS)
    Process: 752 ExecStart=/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port=${PORT} $FLAGS (code=exited, status=1/FAILURE)
    Process: 762 ExecStopPost=/usr/sbin/tailscaled --cleanup (code=exited, status=0/SUCCESS)
   Main PID: 752 (code=exited, status=1/FAILURE)

Dec 30 00:51:00 ubuntu systemd[1]: tailscaled.service: Scheduled restart job, restart counter is at 7.
Dec 30 00:51:00 ubuntu systemd[1]: Stopped Tailscale node agent.
Dec 30 00:51:00 ubuntu systemd[1]: tailscaled.service: Start request repeated too quickly.
Dec 30 00:51:00 ubuntu systemd[1]: tailscaled.service: Failed with result 'exit-code'.
Dec 30 00:51:00 ubuntu systemd[1]: Failed to start Tailscale node agent.

Host computer:

Additional context Performing the same procedure on a Linux server (running ubuntu 22.04), works with no issues.

Please include output of alpine list. Add any other context about the problem here.

alpine list                                                                             
NAME    STATUS      SSH      PORTS    ARCH       PID       TAGS 
lxd     Running     2222     8443     x86_64     94349   
maxzinkus commented 8 months ago

Hi! Thanks for the report. I'll repro this and take a look; it likely has to do with how the layers of virtual network interfaces interact.

idroz commented 5 months ago

Was able to reproduce this in both SLIRP and VMnet-shared modes.

A bit of digging showed that it is related to this: https://github.com/tailscale/tailscale/issues/6941

To fix:

  1. tailscaled --tun=userspace-networking --socks5-server=localhost:54355 --outbound-http-proxy-listen=localhost:54355 &
  2. taliscale up
idroz commented 5 months ago

Closing as not related to macpine, but rather tailscale configuration inside containers with userspace-networking

staticfrost commented 5 months ago

@idroz , did you get it work I can't get CT ubuntu 22.04 to work.

idroz commented 5 months ago

I did. It may be due to timestamp mismatch inside VM and container images.

Inside a macpine VM run hwclock -s to sync the clock and then lxc launch ubuntu:22.04 c