# Docker, Compose and Swarm

Containers are replaced on every deploy, so give each service one canary in the environment file or secret it already loads. Give the Docker host itself a [per-machine canary](/docs/servers) too.

## Compose

Write the decoy to an environment file that only you can read, next to the service's other secrets:

```sh
umask 077
curl -fsSL https://get.snitchwallet.com | sh -s -- --decoy env:- --name prod-compose > ./secrets/payout.env
```

Load it in the service:

```yaml
services:
  api:
    env_file:
      - ./secrets/payout.env
```

Keep `./secrets/` out of git, like your other secrets.

## docker run

```sh
docker run --env-file ./secrets/payout.env your-image
```

## Swarm

Create a Swarm secret straight from the pipe:

```sh
curl -fsSL https://get.snitchwallet.com | sh -s -- --decoy env:- --name prod-swarm | docker secret create payout_signer -
```

Give it to the service; each container sees it at `/run/secrets/payout_signer`:

```yaml
services:
  api:
    secrets:
      - payout_signer

secrets:
  payout_signer:
    external: true
```

## Never in the image

Don't `COPY` a decoy into an image or set it with `ENV` in a Dockerfile. Images get pushed, cached and pulled to many places, so a canary in one can't tell you where it leaked.
