Use in deployments
Goal: no value ever shows up in plaintext on screen, in a command history, in the clipboard or in a command line. There are two ways to get there.
Docker host without the CLI: env files with hostenv (recommended)
If the server only runs Docker, secrets-tool hostenv writes the env files onto the host from your PC: readable by root only, without any value appearing in the console. The deployment one-liners then only contain --env-file and a check that the file matches the current state. How it works: Getting env files onto the host.
Not recommended: values with -e in the one-liner
docker run … -e DB_PASSWORD=$env:DB_PASSWORD … puts the value into the command. It then sits in the screen buffer, the clipboard and the PowerShell history, and on the host in bash_history and the process list. The hostenv way avoids that. secrets-tool check reports such places (see Checking a repository).
What neither way prevents: docker inspect
On docker run, Docker copies the values into the container's configuration, with --env-file just as with -e. docker inspect and docker exec … env then show them in plaintext. Anyone allowed to use Docker on the host (root or the docker group) can read them. The only remedies are restricting Docker and root access on the host, or mounting secrets as files, for example -v /opt/app/secrets:/run/secrets:ro if the app reads *_FILE variables. Then docker inspect only shows the path.
CLI on the server: decrypt at runtime
If the CLI is set up on the server (its own key, see External keys under Access and roles), it decrypts into environment variables at runtime. Only the encrypted file rests on the disk.
PowerShell
secrets-tool remote pull shop-backend Invoke-Expression (secrets-tool load)
Bash
secrets-tool remote pull shop-backend eval "$(secrets-tool export | sed 's/^/export /')"
Docker Compose
secrets-tool export > .env # local only, .env in .gitignore docker compose up -d rm .env
With stages
secrets-tool --stage prod remote pull shop-backend Invoke-Expression (secrets-tool --stage prod load)
In CI it is enough to set SECRETS_TOOL_STAGE=prod once as a pipeline variable; then the commands need no --stage. See Stages.