[英]Docker compose environment variables specified with env_file parameter not working inside the dockerfile
This is a snippet of my docker-compose.yml
file which I'm running with docker-compose build percona_dev
.这是我
docker-compose.yml
docker-compose build percona_dev
运行docker-compose.yml
文件的片段。
percona_dev:
build: docker/percona
dockerfile: percona-dev
env_file: docker.env
I've specified environment variables in docker.env
like this:我在
docker.env
指定了环境变量,如下所示:
USERNAME=xxx
PASSWORD=xxx
DESKTOP_IP=192.168.1.1
PLAYBOOK_LOCATION=/path/to/location/
This is the relevant portion of my Dockerfile
called percona-dev
:这是我的
Dockerfile
名为percona-dev
的相关部分:
FROM percona:5.6.24
MAINTAINER xxx
RUN apt-get update && apt-get install wget
RUN wget --ftp-user=$USERNAME --ftp-password=$PASSWORD ftp://$DESKTOP_IP/$PLAYBOOK_LOCATION/inventory/localhost -O /tmp/playbook/hosts
EXPOSE 3306
ENTRYPOINT [“/usr/bin/mysql”]
Unfortunately the environment variables don't get recognized and the build fails with:不幸的是,环境变量没有被识别,构建失败:
Step 5 : RUN wget --ftp-user=$USERNAME --ftp-password=$PASSWORD ftp://$DESKTOP_IP/$PLAYBOOK_LOCATION/inventory/localhost -O /tmp/playbook/hosts
---> Running in 3595b5ce9581
ftp:////inventory/localhost: Invalid host name.
Service 'percona_dev' failed to build:
How do I make sure I can run the build without exposing sensitive environment variables in my Dockerfile or in thefilesystem layer history of my image?我如何确保我可以运行构建而不在我的 Dockerfile 或我的图像的文件系统层历史记录中暴露敏感的环境变量?
environment variables are not available to the build step.环境变量不可用于构建步骤。 See this proposal for making that more obvious in compose and this feature request to support the new build args added to docker 1.9.
请参阅此提案,以在 compose 和此功能请求中使这一点更加明显,以支持添加到 docker 1.9 的新构建参数。
The build args will do what you need.构建参数将满足您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.