Keep Docker Compose secrets age-encrypted in git with a container that decrypts them before deploy
10K+
docker-age decrypts the age-encrypted .env files in a git checkout on your server, right before your Docker Compose stacks start. Your secrets stay encrypted in git. It does not encrypt files or start your stacks.
docker-age lets you commit every secret encrypted and still start each stack with a plain .env file:
apps/x/.env next to each apps/x/.env.enc and never changes the encrypted file, so git pull stays clean.<name>.enc, or one file you pipe through it.docker-age is built for Docker Compose stacks deployed from a git checkout, with each secret committed as an age-encrypted file. You need the age command-line tool to encrypt your files and an identity file from age-keygen on each server. Your deploy step must run docker exec before your stacks start.
Two other projects suit a different setup:
docker-age is free software under the Apache-2.0 license.
docker pull cplieger/docker-age:latest
Also published to ghcr.io/cplieger/docker-age with identical images and tags. Release versions are tagged vX.Y.Z alongside latest.
# Example compose for docker-age. See docs/configuration.md and docs/hardening.md for all configuration options and hardening.
services:
age:
image: ghcr.io/cplieger/docker-age:latest
container_name: age
# Before each "docker compose up", your deploy step runs
# "docker exec age /age-decrypt decrypt --ext .env" to write the .env files.
restart: unless-stopped # stays up between deploys so the deploy step can reach it
environment:
IDENTITY_PATH: "/age/keys.txt" # required, your age identity file
volumes:
# Put your age identity in keys.txt, then run "sudo chown 65532:65532 keys.txt"
# and "sudo chmod 600 keys.txt" before the first decrypt.
- "/path/to/age-keys:/age:ro"
# Your checkout with the .env.enc files. For each folder that holds one, run
# "sudo chgrp 65532 <folder>" and "sudo chmod g+w <folder>" before the first decrypt.
- "/path/to/repo:/repo"
Apache-2.0. See LICENSE.
The image carries the license text of every bundled component under /usr/share/licenses/, including the BSD-3-Clause text of the age library it links.
Content type
Image
Digest
sha256:41221cbf1…
Size
3 MB
Last updated
2 days ago
docker pull cplieger/docker-age