Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose update container PATH

I want to use docker-compose yml file to update the container's PATH.

environment:
   - PATH="$PATH":/my/new/path

But when I start the container, it says

oci runtime error: exec failed: container_linux.go:265: starting container process caused "exec: \"bash\": executable file not found in $PATH"

Is it possible to update the container's PATH from docker-compose yml file?

Thanks.

like image 990
user890207 Avatar asked Sep 13 '26 18:09

user890207


1 Answers

What you are doing is updating the PATH, however the error is resulting from the fact that $PATH is being expanded to the env variable's value that is on the host.

What you can do is figure the PATH value that is inside the container by default and appending to that value:

  1. Start the image without the variable: docker-compose up

  2. docker exec -it <container-name> bash

  3. run echo $PATH and copy the value
  4. replace the value in the compose file:

environment:
   - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/my/new/path
like image 165
yamenk Avatar answered Sep 16 '26 06:09

yamenk