[英]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. 我想用docker-compose exec [service_name] [shell]
获得交互式提示,如果第一个shell不存在则返回另一个shell。
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) docker-compose exec [service_name] bash
(zsh / bash / sh)
it opens a bash prompt and then inside the container I run 它打开一个bash提示符然后在我运行的容器内
(which zsh && zsh) || (which bash && bash) || (which sh && sh)
and it works fine, it changes the shell to zsh. 它工作正常,它将shell更改为zsh。
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"
. 如果有一个像/bin/sh
这样的入口点,那么你的命令需要是-c "command"
。 Since I don't have your docker-compose setup, here's a docker setup that may be similar: 由于我没有你的docker-compose设置,这里的docker设置可能类似:
docker run -ti --entrypoint /bin/sh --rm alpine -c \
"(which zsh && zsh) || (which bash && bash) || (which sh && sh)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.