Reputation: 445
I want to add a http_proxy environment variable to the nodejs alpine docker image.
The Dockerfile looks like this
FROM node:6-alpine
RUN export
RUN export https_proxy='http://myproxy:8080'
RUN export http_proxy='http://myproxy:8080'
RUN export
The output when running
docker build -t myimage:latest .
looks like this
Step 1/5 : FROM node:6-alpine
---> 66cf88e4fc20
Step 2/5 : RUN export
---> Running in 61f5bda7989d
export HOME='/root'
export HOSTNAME='26ba10d264c2'
export NODE_VERSION='6.9.5'
export NPM_CONFIG_LOGLEVEL='info'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/'
export SHLVL='1'
---> f04aeb89f7d0
Removing intermediate container 61f5bda7989d
Step 3/5 : RUN export https_proxy='http://myproxy:8080'
---> Running in 895d13321da8
---> 6a8aaa9639a9
Removing intermediate container 895d13321da8
Step 4/5 : RUN export http_proxy='http://myproxy:8080'
---> Running in 19910745f212
---> 1de5b4fb2b2e
Removing intermediate container 19910745f212
Step 5/5 : RUN export
---> Running in e5d186b66385
export HOME='/root'
export HOSTNAME='26ba10d264c2'
export NODE_VERSION='6.9.5'
export NPM_CONFIG_LOGLEVEL='info'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/'
export SHLVL='1'
---> 0aa0f97555bf
Removing intermediate container e5d186b66385
Successfully built 0aa0f97555bf
As you can see the export on the shell is not done!
When I open a shell in the newly build image and execute the commands manually it works.
> docker run myimage:latest sh
/ # export https_proxy='http://myproxy:8080'
/ # export http_proxy='http://myproxy:8080'
/ # export
export HOME='/root'
export HOSTNAME='a759e3d30481'
export NODE_VERSION='6.9.5'
export NPM_CONFIG_LOGLEVEL='info'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/'
export SHLVL='1'
export TERM='xterm'
export http_proxy='http://myproxy:8080'
export https_proxy='http://myproxy:8080'
So what am I doing wrong?
Upvotes: 0
Views: 1363
Reputation: 32176
This is not the correct way to define ENV variable in a Dockerfile, better use ENV
see the doc https://docs.docker.com/engine/reference/builder/#/env
and by the way, group your RUN, see the doc explaining it
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
Upvotes: 1