Skip to main content How to connect docker containers to tailscale? : r/Tailscale
r/Tailscale icon
Go to Tailscale
•

How to connect docker containers to tailscale?

Help Needed

I've read through several posts here but haven't found (or rather understood) a straightforward method to connect a docker container to my tailscale network. I am running tailscale on the host machine (not in a docker container) and I would like to connect my delugevpn docker container to this network. I've tried to set up exit nodes and port-forwarding but I'm having a difficult time understanding the process for this. Does anyone have any guidance for this process? Thanks!

You Can Just Do Things with Unraid. Run what you want, how you want. Mix and match drives, use any hardware—no sysadmin skills needed. Try Unraid free for 60 days!
Thumbnail image: You Can Just Do Things with Unraid. Run what you want, how you want. Mix and match drives, use any hardware—no sysadmin skills needed. Try Unraid free for 60 days!
Sort by:
Best
Open comment sort options
• • Edited

This looks like a convenient solution! However, when trying to run compose it gives me the error: yaml: line 8: did not find expected key. Line 8 in my compose file is where the environment variables start. I added a newly generated auth key to TAILSCALE_AUTHKEY so I'm not sure why I'm getting this error. Any suggestions?

Edit: I moved the mod snippet to the top of the environment variables section and now I get the error yaml: line 8: did not find expected '-' indicator. I do have the '' - ' in place though. I am supposed to add the mod snippet to the environment variables of the delugevpn container, correct?

More replies

You can just specify that the docker's ports attach to the Tailscale IP address like this:

<tailscale-ip>:port:port for e.g. 100.34.89.23:80:80

• • Edited

The networking should be in the host mode, right?

What if it’s bridged, like connected to the network of a reverse proxy container?

Can you have one Tailscale instance on the host, accessing all containers instead of one side car container for each application container, like suggested here

https://tailscale.com/blog/docker-tailscale-guide

More replies

So under the ports section of the container (in the compose file) just add - <tailscale-ip>:port:port? With the correct IP and port numbers ofc.

More replies

I know I'm late to the party, but this might be the solution I'm looking for. In theory you would:

  1. Install Tailscale on the machine running docker.

  2. List "<tailscale-ip>:port:port" for the ports in the config file of each docker container.

Now you should be able to access the all the docker containers from a machine inside your tailnet without exposing any ports on the host machine? Also, you wouldn't have to do the service linking, correct?

More replies