This guide provides step-by-step instructions to set up The Things Stack using Docker, starting from configuration files provided separately.
- Useful Links
 - Prerequisites
 - Step 1: Get Required Files
 - Step 2: Clone The Things Stack Repository
 - Step 3: Set Up Configuration Files
 - Step 4: Configure Your Environment (
.envfile) - Step 5: Prepare the Database and Services
 - Step 6: Start The Things Stack
 - Step 7: Access the Console
 
Make sure you have the following software installed on your system:
- Docker
 - Docker Compose
 - Git
 
First, download the necessary configuration files. These should be provided to you (e.g., from a Gist or a separate repository).
env.exampledocker-compose.ymlttn-lw-stack-docker.yml
Create a temporary working directory and place these three files inside it.
Now, clone the official repository from The Things Network. This command will create a lorawan-stack directory.
git clone https://github.com/TheThingsNetwork/lorawan-stackMove the files you downloaded into the correct locations within the lorawan-stack directory.
From your temporary directory (where you downloaded the files), run:
mv docker-compose.yml env.example lorawan-stack/mv ttn-lw-stack-docker.yml lorawan-stack/config/stack/All subsequent commands should be run from inside the lorawan-stack directory.
cd lorawan-stackUse the env.example file as a template to create your local environment file.
cp env.example .envNow, edit the .env file with your specific configuration. Pay close attention to the following:
NETWORK_HOST: Your public domain orlocalhost.NETWORK_BASE_URL: The full URL, e.g.,https://your.domain.comorhttps://localhost.SENDER_ADDRESS,SMTP_ADDRESS, etc.: Your email sending credentials.ACME_EMAIL,ACME_HOST: Your email and domain for Let's Encrypt certificates.- Security Secrets: These are critical. You must set secure, unique values.
 
You can use openssl to generate secrets from your terminal:
# For COOKIE_BLOCK_KEY (32 bytes)
openssl rand -hex 32
# For COOKIE_HASH_KEY (64 bytes)
openssl rand -hex 64Ensure CONSOLE_CLIENT_SECRET is also set to a strong, unique secret.
These commands will initialize the database, create the administrator user, and set up OAuth clients. Docker Compose will automatically load the variables from your .env file.
docker compose run --rm stack is-db migrateThis creates the initial administrator user for your stack. Replace [email protected] with the admin's actual email.
docker compose run --rm stack is-db create-admin-user --id admin --email [email protected]You will be prompted to enter and confirm a password for the admin user.
docker compose run --rm stack is-db create-oauth-client \
  --id cli \
  --name "Command Line Interface" \
  --owner admin \
  --no-secret \
  --redirect-uri "local-callback" \
  --redirect-uri "code"This command uses variables directly from your .env file to configure the Console.
docker compose run --rm stack is-db create-oauth-client \
  --id "console" \
  --name "Console" \
  --owner "admin" \
  --secret "${CONSOLE_CLIENT_SECRET}" \
  --redirect-uri "${NETWORK_BASE_URL}/console/oauth/callback" \
  --redirect-uri "/console/oauth/callback" \
  --logout-redirect-uri "${NETWORK_BASE_URL}/console" \
  --logout-redirect-uri "/console"Once all preparation steps are complete, start the services in detached mode.
docker compose up -dYou can check the logs to ensure everything is running correctly:
docker compose logs -fYou can now access the web console by navigating to the URL you configured as NETWORK_BASE_URL in your .env file. For example:
https://localhost/console
Or if you used a custom domain:
https://your.domain.com/console
Log in with your admin user ID (admin) and the password you created in Step 5.