I am trying to append to the container Path from my dockerfile however when I build the docker file and run the container the changes I have made are not reflected in the container Path
RUN echo "export PATH=/go-dependencies:$PATH:/home/skyctl/bin:/home/skyctl/.local/bin:/dependencies" >> ~/.bashrc
I ran the command above however none of the Paths added are reflected once the container is running
2
Answers
You have to use a speciel layer-command for this in the Dockerfile instead of
RUN
.E.g.:
It’s documented here as Environment Replacement
Since the RUN line of the Dockerfile seems corrects, the issue is that you need to run the Docker image in interactive mode, such as:
This happens because during the build of the image the RUN command isn’t interactive, so it isn’t able to source the .bashrc file.
When you build the Dockerfile, probably there will be warnings/info prompted in the logs that explain to you this.