Get started
Login
© 2024

Add a Docker container

This topic is a quick guide for installing Docker and adding a container to a tailnet. For more detailed information, see Using Tailscale with Docker. For more information about using Docker products in general, see the official Docker documentation.

Install Docker

  1. Download Docker on a Linux device or a cloud VM:

    curl -fsSL https://get.docker.com -o install-docker.sh
    
  2. Run the Docker installation script:

    sudo sh install-docker.sh
    
  3. Enter your password when prompted.

  4. Modify your user Linux user group permission for Docker to interact with it without needing to use sudo.

    sudo usermod -aG docker username
    

We highly recommend you also refer to the Docker topic Manage Docker as a non-root user for more information.

  1. Log out of the terminal session then log back in to allow the permission change to occur.

  2. Run the follow command to verify that the Docker Engine is installed:

    docker run --rm hello-world
    

Create a container for Tailscale

You can use Docker to deploy containers for many kinds of use cases. The instructions below explain how to configure an Ngnix web server and connect it to your tailnet.

  1. Create a Docker compose yaml file using your preferred terminal text editor:

    vi docker-compose.yaml
    
  2. In the yaml file, replace the sample auth key in the TS_AUTHKEY field, with your own. To do this, open the Keys page of the admin console. Select Generate auth key, provide a key name, toggle Resusable to on, and select Generate key. Copy the key and paste it into the TS_AUTHKEY field in the yaml file.

  3. In the yaml file, make sure the service name (immediately below services) matches the network_mode field.

    The Docker yaml file with the service highlighted.

    This yaml file is instructing Docker to create an Nginx web server container with the hostname banana and add it to the tailnet.

  4. Save the changes in your yaml file.

  5. Start up the container and wait for the process to complete:

    docker compose up -d
    
  6. Open the Machines page of the admin console, and you should now see the node banana added to the list.

You can now verify that the Nginx web server is available by going to http://hostname (in this case hostname is banana) and you should see a "Welcome to ngnix" page display.

Last updated Dec 20, 2024