简体   繁体   English

使用sudo运行docker-compose时docker-compose.yml文件中的变量替换

[英]Variable substitution in docker-compose.yml file when running docker-compose with sudo

I'm currently trying to use variable substitution in a docker-compse.yml file. 我目前正在尝试在docker-compse.yml文件中使用变量替换。 This file contains the following: 该文件包含以下内容:

jenkins:
  image: "jenkins:${JENKINS_VERSION}"
  external_links:
      - mongodb:mongo
  ports:
    - 8000:8080

The image below shows what happens when I try to start everything up. 下图显示了当我尝试启动所有内容时发生的情况。

Docker组合变量未设置

As you can see, docker-compose shows a warning saying that the variable is not set. 如您所见,docker-compose显示警告,提示未设置变量。 I suspect this is caused due to the use of sudo to start docker-compose. 我怀疑这是由于使用sudo启动docker-compose引起的。 My setup (a Jenkins docker container which has access to docker and docker-compose via volume mounts) currently requires the use of sudo. 我的设置(可通过卷安装访问docker和docker-compose的Jenkins docker容器)当前需要使用sudo。 Would it be better to stop docker requiring sudo , or is there another way to fix this without changing the current setup? 最好停止要求sudo的docker ,还是有另一种方法可以在不更改当前设置的情况下解决此问题?

sudo -E preserve the user environment when running the command. sudo -E在运行命令时保留用户环境。 It should do what you want. 它应该做您想要的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 docker-compose .yml文件中的变量替换 - Variable substitution in docker-compose .yml file 使用docker-compose up时访问docker-compose.yml文件内的环境变量 - Accessing environmental variable inside of docker-compose.yml file when using docker-compose up docker-compose.yml运行docker-compose时的文件错误 - docker-compose.yml file errors on running docker-compose up 移动 docker-compose.yml 文件时,Nginx 图像的 docker-compose 不起作用 - docker-compose of Nginx image doesn't work when the docker-compose.yml file is moved docker-compose在docker-compose.yml中具有多个服务的构建 - docker-compose build with multiple services in docker-compose.yml 尽管docker-compose.yml中的container_name不同,但docker-compose仍会重新创建运行中的容器 - docker-compose recreates a running container despite having a different container_name in the docker-compose.yml 如何在全球范围内显示由 docker-compose 创建的所有正在运行的容器,而不考虑 docker-compose.yml - How to show all running containers created by docker-compose, globally, regardless of docker-compose.yml 带有非默认 docker-compose.yml 文件的 docker-compose ps - docker-compose ps with non-default docker-compose.yml file docker-compose 向上抛出错误错误:在文件“./docker-compose.yml”中,服务必须是映射,而不是 NoneType - docker-compose up throwing error ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType 在没有 docker-compose.yml 文件的情况下杀死 docker-compose 容器 - Kill docker-compose containers without docker-compose.yml file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM