问题
I tried adding to the PATH
in the files ~/.profile
and /etc/profile
as follow.
PATH = $PATH:/required/path
However, it does not work. Then I tried with adding the line show, which did not work either.
export PATH
It did not work even after restarting the container and the host both.
回答1:
If you want to include a /new/path
in the Dockerfile, adding the line:
ENV PATH "$PATH:/new/path"
in Dockerfile should work.
回答2:
Put in your Dockerfile a line ENV PATH xxx
see an example in this Dockerfile https://gist.github.com/deepak/5933685
回答3:
I got the answer for this question in irc chat. Given here for the benefit of anyone who may come across this. Many people have given wrong answers as update the ~/.profile
but that did not work. So use the answer below.
Update the file ~/.bashrc
for user or update the file /etc/enviroment
global for global change which will apply for all users.
In .bashrc
export PATH: export PATH=$PATH:/new/path/bin
In enviroment: PATH=$PATH:/new/path/bin
来源:https://stackoverflow.com/questions/28722548/updating-path-environment-variable-permanently-in-docker-container