I'm trying to deploy a container and dynamically set the correct configuration (dev, qa, prod) at run time
basically I want to do this....(which doesn't work)
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
WORKDIR /usr/share/nginx/html
COPY dist/ .
CMD cp configuration.$env.json configuration.json
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]
And then when I start the container I pass the env that I want
docker run -d -p 8080:80 --name MyUI -e env=qa myimage
Ideally I want the CMD to be a shell command, so I get the environment var and the ENTRYPOINT to be exec form (if this is possible)
答案 0 :(得分:0)
您是否尝试过使用ARG
?另外,如果这些只是qa,prod等,那么还可以,但是如果您打算以这种方式使用机密,那么最好使用env_file
并将其加密为ARG
留下痕迹