使用 docker swarm 和 compose 文件的秘密

Using secrets with docker swarm and a compose file

如果我没理解错的话,为了正确使用secretI need to use docker swarm.

一旦我做了 'docker swarm init',portainer 就注意到了差异并将所有东西放回 swarm 中:运行ning 容器、现有堆栈等。 但是,在将秘密添加到 portainer 中现在可用的秘密部分后,我尝试设置的堆栈找不到相应的秘密。

这是撰写:https://pastebin.com/H1wnBLjy

这是秘密页面:

如果我在容器中尝试 运行ning ls /run/secrets/ 我会收到此错误:

Error response from daemon: Container xxx is restarting, wait until the container is running

日志不断重复:

Loading configuration from /wiki/config.yml... OK
DB_PASS_FILE is defined. Will use secret from file.
Failed to read Docker Secret File using path defined in DB_PASS_FILE env variable!
ENOENT: no such file or directory, open '/run/secrets/db_passwd'

我尝试删除容器然后重新设置它们,重新启动它们,到目前为止没有任何效果。

有关信息,它是 运行 在带有 portainer 2.6.3 的 Swarm 20.10.7 上,在 debian buster 主机上。

我做错了什么?

感谢您的帮助。

不好意思,如果环境变量没有明确定义,它就不能使用。 我认为将 _FILE 添加到任何 env 足以让它理解它将通过文件传递,但我了解到情况并非如此。 所以 secrets 一般都是可用的,但如果没有在图像中定义,那就不行了。