We are using Docker swarm to deploy services. We would like to use Docker swarm secrets to store sensitive data (certificate passwords). Is it possible to use Docker secret value inside docker-compose.yml file? Docker client version is 20.10.6, Docker engine version is 19.03.12.
First, we create secret on the host:
printf 'ThisIsCertificatePassword123' | docker secret create CertificatePassword -
docker-compose.yml
version: "3.7"
services:
web:
image: myimage:0.0.1
environment:
ASPNETCORE_ENVIRONMENT: Production
ASPNETCORE_URLS: https://+443;http://+80
ASPNETCORE_HTTPS_PORT: 443
ASPNETCORE_Kestrel__Certificates__Default__Password: # how can we use value of CertificatePassword here?
ASPNETCORE_Kestrel__Certificates__Default__Path: /https/certificate.pfx
deploy:
replicas: 1
secrets:
CertificatePassword:
external: true
We deploy the stack with:
docker stack deploy -c docker-compose.yml MyApplication
How can we use value of Docker secret CertificatePassword inside docker-compose.yml (at ASPNETCORE_Kestrel__Certificates__Default__Password)?