1. Docker
  2. Docker

Prerequisites:

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.