mirror of
https://github.com/jbowdre/tailscale-docker.git
synced 2024-11-25 19:22:18 +00:00
working examples simple and complex
This commit is contained in:
parent
40bf327e69
commit
1009329b49
9 changed files with 86 additions and 2 deletions
21
README.md
21
README.md
|
@ -1,2 +1,19 @@
|
||||||
# tailscale-docker
|
# Tailscale in Docker
|
||||||
Tailscale in Docker without elevated privileges
|
|
||||||
|
Tailscale in Docker without elevated privileges. See associated blog post: https://asselin.engineer/tailscale-docker
|
||||||
|
|
||||||
|
**Replace TAILSCALE_AUTH_KEY in `*/tailscale/start.sh` with your own**: https://login.tailscale.com/admin/settings/keys
|
||||||
|
|
||||||
|
## simple-example
|
||||||
|
|
||||||
|
As explained in the blog post, uses a docker-compose service to add the container in the VPN.
|
||||||
|
|
||||||
|
## complex-example
|
||||||
|
|
||||||
|
Not complex but more complex than the simple-example.
|
||||||
|
A nginx layer is added. It manages two services in independent containers at locations `/service-one` and `/service-two`.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
- auth key as a secret
|
||||||
|
- force reuse hostname in tailscale instead of adding suffix. Example: first start is assigned `hostname`. Then, if container is recreated, Tailscale assigns `hostname-1`
|
16
complex-example/docker-compose.yml
Normal file
16
complex-example/docker-compose.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version: "3.9"
|
||||||
|
services:
|
||||||
|
tailscale:
|
||||||
|
build:
|
||||||
|
context: ./tailscale
|
||||||
|
nginx:
|
||||||
|
build:
|
||||||
|
context: ./nginx
|
||||||
|
depends_on:
|
||||||
|
- service-one
|
||||||
|
- service-two
|
||||||
|
network_mode: "service:tailscale"
|
||||||
|
service-one:
|
||||||
|
image: nginxdemos/hello
|
||||||
|
service-two:
|
||||||
|
image: nginxdemos/hello
|
3
complex-example/nginx/Dockerfile
Normal file
3
complex-example/nginx/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
FROM nginx:1.21
|
||||||
|
# based on debian:bullseye-slim
|
||||||
|
COPY conf.d /etc/nginx/conf.d
|
18
complex-example/nginx/conf.d/default.conf
Normal file
18
complex-example/nginx/conf.d/default.conf
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location /service-one {
|
||||||
|
proxy_pass http://service-one/;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
access_log /dev/stdout;
|
||||||
|
error_log /dev/stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /service-two {
|
||||||
|
proxy_pass http://service-two/;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
access_log /dev/stdout;
|
||||||
|
error_log /dev/stdout;
|
||||||
|
}
|
||||||
|
}
|
4
complex-example/tailscale/Dockerfile
Normal file
4
complex-example/tailscale/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM tailscale/tailscale:v1.29
|
||||||
|
COPY start.sh /usr/bin/start.sh
|
||||||
|
RUN chmod +x /usr/bin/start.sh
|
||||||
|
CMD "start.sh"
|
7
complex-example/tailscale/start.sh
Normal file
7
complex-example/tailscale/start.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/ash
|
||||||
|
echo "Starting TS daemon"
|
||||||
|
tailscaled --tun=userspace-networking &
|
||||||
|
sleep 5
|
||||||
|
tailscale up --authkey=TAILSCALE_AUTH_KEY --hostname=complex-example
|
||||||
|
tailscale status
|
||||||
|
sleep infinity
|
8
simple-example/docker-compose.yml
Normal file
8
simple-example/docker-compose.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
version: "3.9"
|
||||||
|
services:
|
||||||
|
tailscale:
|
||||||
|
build:
|
||||||
|
context: ./tailscale
|
||||||
|
some-service-1:
|
||||||
|
image: nginxdemos/hello
|
||||||
|
network_mode: "service:tailscale"
|
4
simple-example/tailscale/Dockerfile
Normal file
4
simple-example/tailscale/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM tailscale/tailscale:v1.29
|
||||||
|
COPY start.sh /usr/bin/start.sh
|
||||||
|
RUN chmod +x /usr/bin/start.sh
|
||||||
|
CMD "start.sh"
|
7
simple-example/tailscale/start.sh
Normal file
7
simple-example/tailscale/start.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/ash
|
||||||
|
echo "Starting TS daemon"
|
||||||
|
tailscaled --tun=userspace-networking &
|
||||||
|
sleep 5
|
||||||
|
tailscale up --authkey=TAILSCALE_AUTH_KEY --hostname=simple-docker-compose
|
||||||
|
tailscale status
|
||||||
|
sleep infinity
|
Loading…
Reference in a new issue