tailscale-dev/docker-guide-code-examples

Include the server config in the compose file?

plattrap opened this issue · 0 comments

One magic I had to work out is to double the "$" in the config content so that Docker does not try and expand the TS_CERT_DOMAIN string.

Also commented out the funnel line, because if it is in (even set to false), then the container shows as funnel enabled in the
control panel.

---
services:
  ts-nginx-test:
    image: tailscale/tailscale:latest
    container_name: ts-nginx-test
    hostname: nginx-test
    environment:
      - TS_AUTHKEY=${TS_AUTHKEY}
      - TS_EXTRA_ARGS=--advertise-tags=tag:container
      - TS_SERVE_CONFIG=/ts-nginx-test-config
      - TS_STATE_DIR=/var/lib/tailscale
    volumes:
      - ts-nginx-test-data:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    configs:
      - ts-nginx-test-config
    cap_add:
      - net_admin
      - sys_module
    restart: unless-stopped

  nginx-pid-test:
    image: nginx
    container_name: nginx-pid-test1
    network_mode: service:ts-nginx-test
    depends_on:
      - ts-nginx-test

volumes:
  ts-nginx-test-data:
    driver: local
    
configs:
  ts-nginx-test-config:
    content: |
      {
        "TCP": { "443": { "HTTPS": true } },
        "Web": {
          "$${TS_CERT_DOMAIN}:443": {
            "Handlers": {
              "/": {
                "Proxy": "http://127.0.0.1:80"
              }
            }
          }
        },
        "#AllowFunnel": { "$${TS_CERT_DOMAIN}:443": false }
      }