Files
kms/docs/documentation/getting-started/docker.mdx
zeekay 38f7211345 chore: rebrand @infisical/* deps to @hanzo/* aliases, update Dockerfiles and helm
- Alias @infisical/quic → @hanzo/quic and @infisical/pg-view-generator → @hanzo/pg-view-generator
  in package.json using npm alias syntax (resolves same upstream packages)
- Update gateway.ts and sanitized-schema.ts to import from @hanzo/* names
- Rename helm-charts/kms-standalone/templates/infisical.yaml → deployment.yaml
- Update Dockerfiles (backend, standalone, fips) with hanzo branding
- Makefile: use 'docker compose' (v2) and docker-compose.prod.yml
- Update docs to reference kms.hanzo.ai and hanzo tooling
- .gitignore: add common dev artifacts
2026-03-02 07:12:51 -08:00

186 lines
5.5 KiB
Plaintext

---
title: "Docker"
---
The [KMS CLI](/cli/overview) can be added to Dockerfiles to fetch secrets from KMS and make them available as environment variables within containers at runtime.
Prerequisites:
- Have a project with secrets ready in [KMS Cloud](https://kms.hanzo.ai).
- Create an [KMS Token](/documentation/platform/token) scoped to an environment in your project in KMS.
<Tabs>
<Tab title="Docker">
## Dockerfile Modification
Follow the instructions for your specific Linux distribution to add the KMS CLI to your Dockerfile.
<Tabs>
<Tab title="Alpine">
```dockerfile
RUN apk add --no-cache bash sudo wget && wget -qO- \
'https://artifacts-cli.kms.hanzo.ai/setup.apk.sh' | sh \
&& apk add kms
```
</Tab>
<Tab title="RedHat/CentOs/Amazon-linux">
```dockerfile
RUN curl -1sLf \
'https://artifacts-cli.kms.hanzo.ai/setup.rpm.sh' | sh \
&& yum install -y kms
```
</Tab>
<Tab title="Debian/Ubuntu">
```dockerfile
RUN apt-get update && apt-get install -y bash curl && curl -1sLf \
'https://artifacts-cli.kms.hanzo.ai/setup.deb.sh' | bash \
&& apt-get update && apt-get install -y kms
```
</Tab>
</Tabs>
Next, modify the start command of your Dockerfile:
```dockerfile
CMD ["kms", "run", "--", "[your service start command]"]
```
## Launch
Spin up your container with the `docker run` command and feed in your KMS Token.
```console
docker run --env KMS_TOKEN=<your_kms_token> <DOCKER-IMAGE>
```
Your containerized application should now be up and running with secrets from KMS exposed as environment variables within your application's process.
## Example Dockerfile
```dockerfile
# Select your base image (based on your Linux distribution, e.g., Alpine, Debian, Ubuntu, etc.)
FROM alpine
# Add the KMS CLI to your Dockerfile (choose the appropriate block based on your base image)
RUN apk add --no-cache bash sudo wget && wget -qO- \
'https://artifacts-cli.kms.hanzo.ai/setup.apk.sh' | sh \
&& apk add kms
# Install any additional dependencies or packages your service requires
# RUN <additional commands for your service>
# Copy your service files to the container
COPY . /app
# Set the working directory
WORKDIR /app
# Modify the start command of your Dockerfile
CMD ["kms", "run", "--", "npm run start"]
```
</Tab>
<Tab title="Docker Compose">
## Dockerfile Modifications
Follow the instructions for your specific Linux distributions to add the KMS CLI to your Dockerfiles.
<Tabs>
<Tab title="Alpine">
```dockerfile
RUN apk add --no-cache bash sudo wget && wget -qO- \
'https://artifacts-cli.kms.hanzo.ai/setup.apk.sh' | sh \
&& apk add kms
```
</Tab>
<Tab title="RedHat/CentOs/Amazon-linux">
```dockerfile
RUN curl -1sLf \
'https://artifacts-cli.kms.hanzo.ai/setup.rpm.sh' | sh \
&& yum install -y kms
```
</Tab>
<Tab title="Debian/Ubuntu">
```dockerfile
RUN apt-get update && apt-get install -y bash curl && curl -1sLf \
'https://artifacts-cli.kms.hanzo.ai/setup.deb.sh' | bash \
&& apt-get update && apt-get install -y kms
```
</Tab>
</Tabs>
Next, modify the start commands of your Dockerfiles:
```dockerfile
CMD ["kms", "run", "--", "[your service start command]"]
```
## Example Dockerfile
```dockerfile
# Select your base image (based on your Linux distribution, e.g., Alpine, Debian, Ubuntu, etc.)
FROM alpine
# Add the KMS CLI to your Dockerfile (choose the appropriate block based on your base image)
RUN apk add --no-cache bash sudo wget && wget -qO- \
'https://artifacts-cli.kms.hanzo.ai/setup.apk.sh' | sh \
&& apk add kms
# Install any additional dependencies or packages your service requires
# RUN <additional commands for your service>
# Copy your service files to the container
COPY . /app
# Set the working directory
WORKDIR /app
# Modify the start command of your Dockerfile
CMD ["kms", "run", "--", "[your service start command]"]
```
## Docker Compose File Modification
For each service you want to inject secrets into, set an environment variable called `KMS_TOKEN` equal to a unique identifier variable. For example:
```yaml
services:
api:
build: .
image: example-service-2
environment:
- KMS_TOKEN=${KMS_TOKEN_FOR_API}
...
```
## Export shell variables
Next, set the shell variables you defined in your compose file. Continuing from the previous example:
```console
export KMS_TOKEN_FOR_API=<your_kms_token>
```
## Launch
Spin up your containers with the `docker-compose up` command.
```console
docker-compose up
```
Your containers should now be running with the secrets from KMS available inside as environment variables.
</Tab>
</Tabs>
See also:
- [Documentation for Docker](/integrations/platforms/docker)
- [Documentation for Docker Compose](/integrations/platforms/docker-compose)