mirror of
https://github.com/Infisical/infisical.git
synced 2026-05-02 03:02:03 -04:00
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
---
|
|
title: "Docker"
|
|
---
|
|
|
|
Infisical can be used in a Dockerfile to inject environment variables into a Docker container.
|
|
|
|
## Add the CLI to your Dockerfile
|
|
|
|
<Tabs>
|
|
<Tab title="Alpine">
|
|
```dockerfile
|
|
RUN apk add --no-cache bash curl && curl -1sLf \
|
|
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \
|
|
&& apk add infisical
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="RedHat/CentOs/Amazon-linux">
|
|
```dockerfile
|
|
RUN curl -1sLf \
|
|
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' | sh \
|
|
&& yum install -y infisical
|
|
```
|
|
</Tab>
|
|
<Tab title="Debian/Ubuntu">
|
|
```dockerfile
|
|
RUN apt-get update && apt-get install -y bash curl && curl -1sLf \
|
|
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' | bash \
|
|
&& apt-get update && apt-get install -y infisical
|
|
```
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Modify your Dockerfile start command
|
|
|
|
To make your Docker container consume Infisical secrets, you can start your application with Infisical.
|
|
This will automatically pull the necessary secrets and make them available to your application as if they were natively exposed within the container.
|
|
|
|
```dockerfile
|
|
CMD ["infisical", "run", "---", "[your application start command]"]
|
|
|
|
# example with single single command
|
|
CMD ["infisical", "run", "---", "npm run start"]
|
|
|
|
# example with multiple commands
|
|
CMD ["infisical", "run", "--command" "npm run start && ..."]
|
|
```
|
|
|
|
View more options for the `run` command [here](../../cli/commands/run)
|
|
|
|
## Feed Docker your Infisical Token
|
|
|
|
The CLI looks out for an environment variable called `INFISICAL_TOKEN`. If the token is detected, the CLI will authenticate, retrieve, and inject the environment variables which the token is authorized for.
|
|
|
|
```bash
|
|
docker run --env INFISICAL_TOKEN=[token]...
|
|
```
|
|
|
|
## Generate an Infisical Token
|
|
|
|
[Generate an Infisical Token](../../getting-started/dashboard/token) and keep it handy.
|
|
|