True to the mission to have the same features available in all supported flavours, Docker introduced secrets in Compose YAML format version 3.1.
We'll continue using Docker Flow Proxy to demonstrate how secrets work inside Compose files:
curl -o dfp.yml \
https://raw.githubusercontent.com/vfarcic/\
docker-flow-stacks/master/proxy/docker-flow-proxy-secrets.yml
We downloaded the docker-flow-proxy-secrets.yml (https://github.com/vfarcic/docker-flow-stacks/blob/master/proxy/docker-flow-proxy-secrets.yml) stack from the vfarcic/docker-flow-stacks (https://github.com/vfarcic/docker-flow-stacks) repository.
The relevant parts of the definition of the stack are as follows:
version: "3.1"
...
services:
proxy:
image: vfarcic/docker-flow-proxy:${TAG:-latest}
ports:
- 80:80
- 443:443
networks:
- proxy
environment:
- LISTENER_ADDRESS...