找不到 docker 个机密文件夹(“/run/secrets”)
Can't find docker secrets' folder ('/run/secrets')
我玩过https://labs.play-with-docker.com/。
我选择了3 Managers and 2 Workers
的模板:
我去了 manager1
并创建了一个秘密:
echo "mydatabasepassword" | docker secret create db_pass -
我检查过,秘密是存在的:
我想查看 secrets 文件夹,但它不存在:
我也这样试过:
知道它在哪里吗?
根据 Bret Fisher 的回答,这里有一个例子:
*我只能从经理领导那里得到容器的名称。
根据 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.
(要了解有关加密 Raft 日志的更多信息,请参阅 here。)
秘密存储在管理器主机上的加密 raft 数据库中,因此您无法从主机查看它们。要在容器中查看它们,您需要在 docker 服务创建时分配它们,因此:
docker service create --secret=db_pass --name example nginx
然后从分配容器的节点可以看到容器中的文本文件(容器名称会有所不同):
docker exec example.1.m1c4bvubej64xc1csclnq7y3r cat /run/secrets/db_pass
我玩过https://labs.play-with-docker.com/。
我选择了3 Managers and 2 Workers
的模板:
我去了 manager1
并创建了一个秘密:
echo "mydatabasepassword" | docker secret create db_pass -
我检查过,秘密是存在的:
我想查看 secrets 文件夹,但它不存在:
我也这样试过:
根据 Bret Fisher 的回答,这里有一个例子:
*我只能从经理领导那里得到容器的名称。
根据 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.
(要了解有关加密 Raft 日志的更多信息,请参阅 here。)
秘密存储在管理器主机上的加密 raft 数据库中,因此您无法从主机查看它们。要在容器中查看它们,您需要在 docker 服务创建时分配它们,因此:
docker service create --secret=db_pass --name example nginx
然后从分配容器的节点可以看到容器中的文本文件(容器名称会有所不同):
docker exec example.1.m1c4bvubej64xc1csclnq7y3r cat /run/secrets/db_pass