This script creates Docker containers from different images and connects each container to a Tailscale network.
The users.txt file contains a list of users, one per line. Each row represents a user and their associated container. The first column is the username, and the second column is the Docker image name.
Run the script with .\create-containers.sh add users.txt to add the missing containers, use the recreate option to delete and recreate each container if existing.
To build a Docker image from a Dockerfile, use the following command:
docker build -f Dockerfile.tag -t image-name:tag .Container run options (except for ports), such as GPU support or volume mounts, can be specified in the DOCKER_OPTS variable.
Ports to be exposed through Tailscale must be defined in the PORT_OPT variable. For example, if you want to expose ports 5901 and 6080, set PORT_OPT accordingly. Update every occurrence as needed for your services.
Edit the YAML file at ./tsdproxy/tsdproxy-conf to add your Tailscale authentication key. Generate a key at Tailscale Admin Console (select "Reusable" and set the duration to 90 days).
From the tsdproxy directory, start the proxy container with:
docker compose up -dAfter making configuration changes, restart the container. Tailscale nodes are automatically added when containers are created.
The compose-containers.sh script is designed to automate the creation and management of Docker containers for development environments. It supports connecting containers to a Tailscale network and forwarding ports for remote access.
-
Input File: Prepare a text file (e.g.,
users.txt) listing users and their associated Docker images. Each line should follow the format:username docker-image-nameLines starting with
#are treated as comments and ignored. -
Tailscale Auth Key: Obtain a valid Tailscale authentication key, it must be reusable.
Run the script with the following syntax:
./compose-containers.sh <mode> <user_image_file.txt> <tailscale_auth_key><mode>: Specifyaddto create new containers orrecreateto delete and recreate existing containers.<user_image_file.txt>: Path to the input file containing user and image mappings.<tailscale_auth_key>: Your Tailscale authentication key.
To add containers for users listed in users.txt:
./compose-containers.sh add users.txt ts-auth-keyTo recreate containers:
./compose-containers.sh recreate users.txt ts-auth-key- Reads Input File: Processes each user and their Docker image.
- Generates Docker Compose Configurations: Creates a
docker-compose.ymlfile for each user in thedeploymentsdirectory. - Launches Containers: Starts the containers using Docker Compose.
- Port Forwarding: Sets up port forwarding for SSH, VNC, and NoVNC access.
- Docker Compose configurations are stored in
deployments/<user_project_name>/docker-compose.yml. - A Tailscale Serve config is generated at
deployments/<user_project_name>/serve-config.jsonto enable HTTPS for noVNC. - Containers are launched with the following access details:
- SSH:
ssh <container_name> - noVNC Access:
https://<container_name>(HTTPS via Tailscale Serve)
- SSH:
Note: HTTPS certificates must be enabled in your Tailscale admin console under DNS → HTTPS Certificates at https://login.tailscale.com/admin/dns.