DDEV/docker-compose:使用绝对路径绑定挂载路径
我试图在 ddev 中定义一个卷,如下所示:
文件名:docker-compose.salesforce.yaml
内容:
version: '3.6'
services:
web:
volumes:
- /Users/dmgig/JWT:/home/dmgig/JWT:rw
但正如你所看到的,它使用我的用户名,我想让它工作对于任何人。
我试图找到一个主目录变量,但找不到。
我假设了这样的事情:
version: '3.6'
services:
web:
volumes:
- $HOME/JWT:$HOME_DDEV/JWT:rw
我该如何编写它,以便它使用主机和 ddev 机器的正确路径?
I'm trying to define a volume in ddev like this:
Filename: docker-compose.salesforce.yaml
Contents:
version: '3.6'
services:
web:
volumes:
- /Users/dmgig/JWT:/home/dmgig/JWT:rw
But as you can see it uses my user name and I'd like to make it work for anyone.
I've tried to find a home directory variable, but can't find one.
I assumed something like:
version: '3.6'
services:
web:
volumes:
- $HOME/JWT:$HOME_DDEV/JWT:rw
How would I write this so that it uses the correct paths for the host and the ddev machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试将主机从主机安装到容器内吗?/JWT?
通过Docker-Compose在主机上评估环境变量,该变量对容器内部的内容一无所知,因此您需要像已经做过的那样,在容器内使用绝对的路径。
我认为这可能在Linux或MacOS上对您有用:
You're trying to mount ~/JWT from the host into ~/JWT inside the container?
The environment variables are evaluated on the host by docker-compose, which doesn't know anything about what's inside the container, so you'll need to use absolute paths for inside the container, as you already did.
I think this might work for you on Linux or macOS: