Docker Community Forums

Share and learn in the Docker community.

Change $PATH in ubuntu container so that it is accessible from outside the shell

(Romanhaa) #1

Hi! I’m currently setting up a docker container to run scripts for me on the basis of the official ubuntu image. Everything works fine, scripts have been added to $PATH so that I can call them from within the shell (docker run -it image). However, the scripts are not available if I try to call them directly:

docker run image
docker: Error response from daemon: oci runtime error: exec: "": executable file not found in $PATH.

I tried adding the directories to /etc/profile, but found out that is only being sourced once a shell is started. But also if I add them to /etc/environment they can’t be found. So the question is, where is the $PATH that I need to add my directories to?

All help is appreciated :slight_smile:

(Ranjandas) #2


Where is inside container? Is it in the same directory as I think your is getting triggered.

To see the PATH variables in the container you can run as shown below.

docker run image env | grep PATH

And instead of setting PATH variable inside /etc/profile and /etc/environment, you can just add environment variable in Dockerfile


ENV PATH=$PATH:/my/script/path/

Hope this helps.

(Romanhaa) #3

Thank you for the hints! I ended up defining the PATH in the Dockerfile and it works fine. However, those variables show up twice in my PATH if I use the ‘grep | PATH’ command :smiley: Not a big deal, will figure that out later.

Thanks again!