Docker
The Infisical CLI can be added to Dockerfiles to fetch secrets from Infisical and make them available as environment variables within containers at runtime.
Prerequisites:
- Have a project with secrets ready in Infisical Cloud.
- Create an Infisical Token scoped to an environment in your project in Infisical.
Dockerfile Modification
Follow the instructions for your specific Linux distribution to add the Infisical CLI to your Dockerfile.
Next, modify the start command of your Dockerfile:
Launch
Spin up your container with the docker run
command and feed in your Infisical Token.
Your containerized application should now be up and running with secrets from Infisical exposed as environment variables within your application’s process.
Example Dockerfile
Dockerfile Modification
Follow the instructions for your specific Linux distribution to add the Infisical CLI to your Dockerfile.
Next, modify the start command of your Dockerfile:
Launch
Spin up your container with the docker run
command and feed in your Infisical Token.
Your containerized application should now be up and running with secrets from Infisical exposed as environment variables within your application’s process.
Example Dockerfile
Dockerfile Modifications
Follow the instructions for your specific Linux distributions to add the Infisical CLI to your Dockerfiles.
Next, modify the start commands of your Dockerfiles:
Example Dockerfile
Docker Compose File Modification
For each service you want to inject secrets into, set an environment variable called INFISICAL_TOKEN
equal to a unique identifier variable. For example:
Export shell variables
Next, set the shell variables you defined in your compose file. Continuing from the previous example:
Launch
Spin up your containers with the docker-compose up
command.
Your containers should now be running with the secrets from Infisical available inside as environment variables.
See also:
Was this page helpful?