Updating PATH environment variable permanently in Docker container

百般思念 提交于 2019-11-27 10:41:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!