---
title: "Docker"
description: "Pass Ennote secrets to Docker containers without .env files: inject them into docker run or docker compose with ennote secret get, or run the Ennote CLI inside the container as the entrypoint."
canonical_url: "https://docs.ennote.io/cli/guides/docker"
---
# Docker

> Pass Ennote secrets to Docker containers without .env files: inject them into docker run or docker compose with ennote secret get, or run the Ennote CLI inside the container as the entrypoint.

## Option 1: inject into `docker run`

`ennote secret get <secret> -- <command>` starts the command with each key of the secret as an environment variable. `docker run -e NAME` (without `=value`) copies that variable from the Docker CLI's environment into the container:

```bash
ennote secret get app -- docker run --rm -e DB_PASSWORD -e API_KEY my-image
```

Here `app` is a secret with the keys `DB_PASSWORD` and `API_KEY`. The values are never written to a file or typed on the command line.

## Option 2: Docker Compose

Compose reads variables from the environment it runs in. List the keys under `environment` without values:

```yaml [compose.yaml]
services:
  api:
    image: my-image
    environment:
      - DB_PASSWORD
      - API_KEY
```

Then start Compose through the CLI:

```bash
ennote secret get app -- docker compose up -d
```

## Option 3: the CLI as the container entrypoint

Install the Ennote CLI in the image and let it start your app, so secrets are fetched when the container starts:

```dockerfile [Dockerfile]
FROM alpine:3.20
RUN apk add --no-cache curl \
 && curl -sSfL https://get.ennote.io/get-cli.sh | sh
COPY app /app
ENTRYPOINT ["ennote", "secret", "get", "app", "--"]
CMD ["/app/server"]
```

Provide the token and target at runtime, not at build time:

```bash
docker run --rm \
  -e ENNOTE_TOKEN -e ENNOTE_ORGANIZATION_ID=org_123 -e ENNOTE_WORKSPACE_ID=wrk_prod \
  my-image
```

Never put `ENNOTE_TOKEN` in a `Dockerfile` (`ENV` or `ARG`): it would be stored in the image layers. For Kubernetes, use the [Ennote Kubernetes agent](https://docs.ennote.io/docs/agents/overview) instead, which syncs secrets into native Kubernetes Secrets.

## FAQ

### How do I use Ennote secrets in Docker without a .env file?

Run `ennote secret get <secret> -- docker run -e KEY ...` or `ennote secret get <secret> -- docker compose up`. The secret's keys become environment variables of the Docker CLI, which passes the listed ones to the container.

### Which option should I pick?

Options 1 and 2 keep the image unchanged and need the Ennote CLI only on the host. Option 3 suits platforms that start containers for you, where you can set environment variables but not wrap the start command.

<need-help>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
