Skip to main content
This guide walks you through injecting secrets from Infisical into a Dockerized application as environment variables. You can fetch secrets when the container starts or export them from the host when you run the container.

Prerequisites

Setup

Choose how Docker should receive your application secrets:

Use with Docker Compose

If you fetch secrets at startup, you can use Docker Compose to build and run one or more configured service images. Configure each image to start through infisical run, then configure your Compose file for your Infisical deployment:
Authenticate the machine identity in the same shell, then start the services using the commands for your Infisical deployment:
If your self-hosted Infisical instance is running locally on the Docker host, don’t set INFISICAL_DOMAIN to a localhost URL, since this will point to the container itself.Instead, set it to a host.docker.internal URL, which points to the container’s host domain.

Use different permissions for each service

If multiple services need different access permissions, create a machine identity for each permission set and pass each access token through a separate variable. Map each service to the access token for its machine identity:
Authenticate each identity before starting the services: