- Docker
- Docker
Docker
Docker
How to use Infisical to inject environment variables into a Docker container.
Prerequisites:
- Set up and add envars to Infisical Cloud
Add the Infisical CLI to your Dockerfile
Alpine
RedHat/CentOs/Amazon-linux
Debian/Ubuntu
RUN apk add --no-cache bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \
&& apk add infisical
Modify the start command in your Dockerfile
Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service.
CMD ["infisical", "run", "--", "[your service start command]"]
# example with single single command
CMD ["infisical", "run", "--", "npm", "run", "start"]
# example with multiple commands
CMD ["infisical", "run", "--command", "npm run start && ..."]
Generate an Infisical Token
Head to your project settings in Infisical Cloud to generate an Infisical Token.
Feed Docker your Infisical Token
docker run --env INFISICAL_TOKEN=[token] [DOCKER-IMAGE]...
The Infisical CLI uses the detected INFISICAL_TOKEN
environment variable to authenticate, retrieve, and inject the environment variables which the token is authorized for.