DDEV/docker-compose:使用绝对路径绑定挂载路径

发布于 2025-01-18 02:06:17 字数 435 浏览 3 评论 0原文

我试图在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香橙ぽ 2025-01-25 02:06:17

您正在尝试将主机从主机安装到容器内吗?/JWT?

通过Docker-Compose在主机上评估环境变量,该变量对容器内部的内容一无所知,因此您需要像已经做过的那样,在容器内使用绝对的路径。

我认为这可能在Linux或MacOS上对您有用:

services:
  web:
    volumes:
      - /Users/$USER/JWT:/home/$USER/JWT:rw

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:

services:
  web:
    volumes:
      - /Users/$USER/JWT:/home/$USER/JWT:rw
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文