Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 946
E235 Avatar asked Oct 28 '25 13:10

E235


2 Answers

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
like image 120
Bret Fisher Avatar answered Oct 31 '25 13:10

Bret Fisher


As per the docs:

When you grant a newly-created or running service access to a secret, the decrypted secret is mounted into the container in an in-memory filesystem. The location of the mount point within the container defaults to /run/secrets/ in Linux containers

The secrets are stored in the encrypted Raft logs for the swarm.

(To learn more about the encrypted Raft logs, see here.)

like image 36
ldg Avatar answered Oct 31 '25 12:10

ldg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!