I want to just print HOMEPATH variable from my machine:
This is my Dockerfile:
FROM python:3.8-slim
ARG some_path=$HOMEPATH
RUN echo "this is some_path: $some_path"
but receiving empty string, during image creation - docker build -t test_image . :
What I am doing wrong ?
CodePudding user response:
Docker doesn't expose the builder to this sort of security risk. The build environment could have sensitive data in environment variables that they do not want exposed when the build arbitrary docker images. To inject a variables during build, you must explicitly pass it on the build command line with:
docker build --build-arg "some_path=$HOMEPATH" -t test_image .
Note that the path on the build server is typically not something you would want to inject in a build. The same build should work regardless of where you perform the build.