Skip to content

Environment variables and secrets in Compose

Select an icon to see what it is.

Step 3 of 6

Anyone with the Docker API can read them

docker inspect returns Config.Env in plain text. So does anyone who can use the Docker socket, and the values also show in the process's environment on the host. For a password, this is a weak place to keep it.

$ docker inspect --format '{{json .Config.Env}}' shop-api-1

GET /v1.45/containers/shop-api-1/json (Config)

{
"Config": {
"Env": [
"DB_HOST=db"
"DB_PASSWORD=example"
]
}
}