Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

493
Views
docker-compose exec failed: executable file not found in $PATH

I want to get an interactive prompt with docker-compose exec [service_name] [shell] and to fallback on another shell if the first does not exist.

I tried to run the following command:

docker-compose exec [service_name] "(which zsh && zsh) || (which bash && bash) || (which sh && sh)"

but I got this error:

rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"\\\"(which zsh && zsh) || (which bash && bash) || (which sh && sh)\\\"\": executable file not found in $PATH"

If I run

docker-compose exec [service_name] bash (zsh/bash/sh)

it opens a bash prompt and then inside the container I run

(which zsh && zsh) || (which bash && bash) || (which sh && sh)

and it works fine, it changes the shell to zsh.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's not clear what the command inside the container actually is. If there is an entrypoint like /bin/sh, then your command will need to be -c "command". Since I don't have your docker-compose setup, here's a docker setup that may be similar:

docker run -ti --entrypoint /bin/sh --rm alpine -c \
  "(which zsh && zsh) || (which bash && bash) || (which sh && sh)"
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!