Reputation: 955
This is a snippet of my docker-compose.yml
file which I'm running with docker-compose build percona_dev
.
percona_dev:
build: docker/percona
dockerfile: percona-dev
env_file: docker.env
I've specified environment variables in docker.env
like this:
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
:
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?
Upvotes: 2
Views: 1058
Reputation: 28060
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.
The build args will do what you need.
Upvotes: 2