Docker Compose找不到$ PWD环境变量 [英] Docker compose won't find $PWD environment variable

查看:1812
本文介绍了Docker Compose找不到$ PWD环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的docker-compose:

Here's my docker-compose:

version: '2'
services:
  couchpotato:
    build:
        context: ./couchpotato
        dockerfile: Dockerfile
    ports:
     - 5050:5050
    volumes:
     - "${PWD}/couchpotato/data:/home/CouchPotato/data/"
     - "${PWD}/couchpotato/config:/home/CouchPotato/config/"

在外壳中运行时,在docker-compose.yml目录中,我得到:

When I run it inside the shell, in the directory of the docker-compose.yml, I get:

WARNING: The PWD variable is not set. Defaulting to a blank string.

,撰写开始于PWD为空.

and the compose starts with PWD being empty.

我没有在文件中看到任何错误,如下所示: https://docs.docker.com/compose/environment-variables/

I don't see any error in the file, as seen here: https://docs.docker.com/compose/environment-variables/

推荐答案

您不需要${PWD},您只需将路径设为相对路径,然后compose将其展开(撰写路径与已处理路径之间的一个主要区别)通过docker run).

You don't need ${PWD} for this, you can just make the path relative and compose will expand it (one major difference between compose paths and those processed by docker run).

version: '2'
services:
  couchpotato:
    build:
        context: ./couchpotato
        dockerfile: Dockerfile
    ports:
     - 5050:5050
    volumes:
     - "./couchpotato/data:/home/CouchPotato/data/"
     - "./couchpotato/config:/home/CouchPotato/config/"

至于为什么compose看不到此变量,这取决于您的shell. Compose查找导出的环境变量,.env文件的内容以及docker-compose命令的命令行标志.如果这些变量中的每个变量都为空,则会收到该警告.

As for why compose doesn't see this variable, that depends on your shell. Compose looks for an exported environment variable, contents of the .env file, and command line flags to the docker-compose command. If each of those comes up empty for the variable, you'll get that warning.

这篇关于Docker Compose找不到$ PWD环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆