This trivial example allows for passing secret to service
Steps followed for this example
- Initialize swarm cluster:
docker swarm init
- Create secret greeting:
echo "Hello, " | docker secret create greeting -
- Build image:
docker build . -t simple
- Run stack service:
docker stack deploy -c docker-compose.yml simple-stack
- View logs on running container:
docker logs $(docker ps | grep simple | awk '{print $1}')
Output:
Here is the secret greeting: for Brian
Hello, Brian
Credit for this implementation comes from this gist