Add Modal Apps to Tailscale

This example demonstrates how to integrate Modal with Tailscale ( It outlines the steps to configure Modal containers so that they join the Tailscale network.

We use a custom entrypoint to automatically add containers to a Tailscale network (tailnet). This configuration enables the containers to interact with one another and with additional applications within the same tailnet.

import modal

Install Tailscale and copy custom entrypoint script ( The script must be executable.

image = (
    .run_commands("curl -fsSL | sh")
    .copy_local_file("./", "/root/")
        "RUN chmod a+x /root/",
        'ENTRYPOINT ["/root/"]',
stub = modal.Stub(image=image)

Run your function adding a Tailscale secret. It expects an environment variable named TAILSCALE_AUTHKEY. We suggest creating a reusable and ephemeral key.

                "ALL_PROXY": "socks5://localhost:1080/",
                "HTTP_PROXY": "http://localhost:1080/",
                "http_proxy": "http://localhost:1080/",
def connect_to_raspberrypi():
    import requests

    # Connect to other machines in your tailnet.
    resp = requests.get("http://raspberrypi:5000")

Run this script with modal run You will see Tailscale logs when the container start indicating that you were able to login successfully and that the proxies (SOCKS5 and HTTP) have created been successfully. You will also be able to see Modal containers in your Tailscale dashboard in the “Machines” tab. Every new container launched will show up as a new “machine”. Containers are individually addressable using their Tailscale name or IP address.