Skip to main content

Self-hosting guide for Docker

Docker Instance

This Docker Compose project creates a zrok instance and includes a ziti controller and router. An optional Caddy container is included to provide HTTPS and reverse proxy services for the zrok API and public shares.

DNS Configuration

  1. A wildcard record exists for the IP address where the zrok instance will run, e.g. if your DNS zone is, then your wildcard record is *

Additional DNS Configuration for Caddy TLS

The included Caddy container can automatically manage a wildcard certificate for your zrok instance. You can enable Caddy in this compose project by renaming caddy.compose.override.yml as compose.override.yml.

  1. Ensure A Caddy DNS plugin is available for your DNS provider (see
  2. Designate A DNS zone for zrok, e.g. or and create the zone on your DNS provider's platform.
  3. Created an API token in your DNS provider that has permission to manage zrok's DNS zone.

Create the Docker Compose Project

Create a working directory on your Docker host and save these Docker Compose project files.

Shortcut Option

  1. Run this script to download the files in the current directory.

    curl | bash

    Or, specify the Compose project directory.

    curl | bash -s /path/to/compose/project/dir

Manual Option

  1. Get the zrok repo ZIP file.

  2. Unzip the zrok-instance files into the project directory.

    unzip -j -d . '*/docker/compose/zrok-instance/*'

Configure the Docker Compose Project Environment

Create an .env file in the working directory.

.env required

.env options
# Caddy TLS option: rename caddy.compose.override.yml to compose.override.yml and set these vars; allow 80,443 in firewall
# plugin name for your DNS provider
# API token from your DNS provider
# use the staging API until you're sure everything is working to avoid hitting the rate limit

# no TLS option: publish the insecure ports to the internet and allow them in the firewall

# ziti ports must be published to the internet and allowed by firewall

# configure oauth for public shares

# zrok version, e.g., 1.0.0
# ziti version, e.g., 1.0.0

Start the Docker Compose Project

  1. Start the zrok instance.

    The container images for zrok (including caddy) are built in this step. This provides a simple configuration to get started. You can modify the templates named like *.envsubst or mount a customized configuration file to mask the one that was built in.

    docker compose up --build --detach

Set up a User Account

This step creates a user account. You will log in to the zrok web console with the account password created in this step. The ZROK_USER_EMAIL and ZROK_USER_PWD variables are set in the .env file. You can create more user accounts the same way by substituting a different email and password.

Create the first user account
docker compose exec zrok-controller bash -xc 'zrok admin create account /etc/zrok-controller/config.yml ${ZROK_USER_EMAIL} ${ZROK_USER_PWD}'
Example output
+ zrok admin create account /etc/zrok-controller/config.yml zrokuserpw
[ 0.000] INFO zrok/controller/store.Open: database connected
[ 0.002] INFO zrok/controller/store.(*Store).migrate: applied 0 migrations

Create additional users by running the command again with a different email and password.

Create another user
docker compose exec zrok-controller zrok admin create account /etc/zrok-controller/config.yml <email> <password>

Enable the User Environment

You must enable each device environment with the account token obtained when the account was created. This is separate from the account password that's used to log in to the web console.

Follow the getting started guide to install the zrok CLI on some device and enable a zrok environment.

  1. Configure the environment with the zrok API. Substitute the API endpoint with the one you're using, e.g. https://zrok.${ZROK_DNS_ZONE}.

    zrok config set apiEndpoint

    or, if not using Caddy for TLS:

    zrok config set apiEndpoint
  2. Enable an environment on this device with the account token from the previous step.

    zrok enable heMqncCyxZcx

Firewall Configuration

The ziti-quickstart and caddy containers publish ports to all devices that use zrok shares. The zrok-controller and zrok-frontend containers expose ports only to the caddy container and the Docker host's loopback interface.


  1. 443/tcp - reverse proxy handles HTTPS requests for zrok API, OAuth, and public shares (published by container caddy)
  2. 1280/tcp - ziti ctrl plane (published by container ziti-quickstart)
  3. 3022/tcp - ziti data plane (published by container ziti-quickstart)


  1. 80/tcp - reverse proxy redirects non-HTTPS requests to 443/tcp (published by container caddy)


  1. Check the ziti and zrok logs.

    You can substitute the service container name of each to check their logs individually: ziti-quickstart, zrok-controller, zrok-frontend.

    docker compose logs zrok-controller
  2. Check the caddy logs.

    It can take a few minutes for Caddy to obtain the wildcard certificate. You can check the logs to see if there were any errors completing the DNS challenge which involves using the Caddy DNS plugin to create a TXT record in your DNS zone. This leverages the API token you provided in the .env file, which must have permission to create DNS records in the zrok DNS zone.

    docker compose logs caddy
  3. zrok enable fails certificate verification: ensure you are not using the staging API for Let's Encrypt.

    If you are using the staging API, you will see an error about the API certificate when you use the zrok CLI. You can switch to the production API by removing the overriding assignment of the CADDY_ACME_API variable.

    Example output
    there was a problem enabling your environment!
    you are trying to use the zrok service at:
    you can change your zrok service endpoint using this command:

    $ zrok config set apiEndpoint <newEndpoint>

    (where newEndpoint is something like:
    [ERROR]: error creating service client (error getting version from api endpoint '': Get "": tls: failed to verify certificate: x509: certificate signed by unknown authority: Get "": tls: failed to verify certificate: x509: certificate signed by unknown authority)
  4. Validate the Caddyfile.

    docker compose exec caddy caddy validate --config /etc/caddy/Caddyfile
  5. Verify the correct DNS provider module was built-in to Caddy.

    docker compose exec caddy caddy list-modules | grep dns.providers
    Example output
  6. Verify certificates.

    You can check the certificates that Caddy has obtained.

    docker compose exec caddy caddy list-certificates
  7. Use the Caddy admin API.

    You can use the Caddy admin API to check the status of the Caddy instance. The admin API is available on port 2019/tcp inside the Docker Compose project. You can modify compose.override.yml to publish the port if you want to access the admin API from the Docker host or elsewhere.

    docker compose exec caddy curl http://localhost:2019/config/ | jq
  8. My provider, e.g., Route53 doesn't give me a single API token.

    As long as your DNS provider is supported by Caddy then it will work. You can modify the Caddyfile to use a different set of properties than the example. Here's how the tls section should look for Route53.

    tls {
    dns {$CADDY_DNS_PLUGIN} {
    access_key_id {$AWS_ACCESS_KEY_ID}
    secret_access_key {$AWS_SECRET_ACCESS_KEY}