Search code examples
dockerdocker-swarmdocker-secrets

Can't find docker secrets' folder ('/run/secrets')


I played with https://labs.play-with-docker.com/.

I chose the template of 3 Managers and 2 Workers:
enter image description here

I went to manager1 and created a secret:

echo "mydatabasepassword" | docker secret create db_pass -

I checked and the secret is exist:
enter image description here

I wanted to check the secrets folder but it doesn't exist:
enter image description here

I also tried like this:
enter image description here Any idea where can it be ?

Following Bret Fisher answer, here is an example:
enter image description here

*I could get the name of the container only from the manager leader.


Solution

  • Secrets are stored on the manager host in the encrypted raft db, so you can't view them from host. To see them in a container you need to assign them on docker service create, so:

    docker service create --secret=db_pass --name example nginx
    

    Then from the node that was assigned the container you can see the text file in the container (container name will be different):

    docker exec example.1.m1c4bvubej64xc1csclnq7y3r cat /run/secrets/db_pass