docker-secrets-example

This trivial example allows for passing secret to service

Steps followed for this example

  1. Initialize swarm cluster:
    docker swarm init
  2. Create secret greeting:
    echo "Hello, " | docker secret create greeting -
  3. Build image:
    docker build . -t simple
  4. Run stack service:
    docker stack deploy -c docker-compose.yml simple-stack
  5. View logs on running container:
    docker logs $(docker ps | grep simple | awk '{print $1}')

Expected output:

Output:

Here is the secret greeting: for Brian
Hello, Brian

Credit:

Credit for this implementation comes from this gist