skip to Main Content

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


  1. You have to use a speciel layer-command for this in the Dockerfile instead of RUN.
    E.g.:

    ENV PATH="${PATH}:/bin"
    

    It’s documented here as Environment Replacement

    Login or Signup to reply.
  2. 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:

    docker run --name <yourimage> -it debian
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search