Skip to main content
This guide walks you through storing secrets in Infisical and injecting them 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:

Step 1: Configure in Infisical

Create a project

In Infisical, a project holds all secrets for one application or service. To create a project:
1
Log in to Infisical.
2
Select Secrets Management > + Add New Project.
3
In the Project Name field, enter a name for the project (e.g., orders-service).
4
Select Create Project.
This opens your new project in the Development environment:
New project
Within a project, secrets are organized across environments. Every new project starts with three environments: Development, Staging, and Production.

Add your secrets

You have two options for adding secrets to your project:
To create a new secret from scratch:
1
Select + Add a New Secret.
2
In the Key and Value fields, enter a key-value pair. For example:
Key and Value fields
3
Select Create Secret.
4
Repeat these steps for each key-value pair you want to add.

Step 2: Choose a delivery method

Next, 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:

Next steps

Core Concepts

Understand how projects, environments, folders, and secrets fit together.

Secrets Delivery

Explore other ways to deliver secrets to applications and infrastructure.

Machine Identities

Configure workload authentication and access controls.

Infisical Run

Review all options for injecting secrets into an application process.