简体   繁体   English

docker-compose exec失败:在$ PATH中找不到可执行文件

[英]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.

相关问题 docker-compose exec: \“webserver\”: $PATH 中找不到可执行文件 - docker-compose exec: \“webserver\”: executable file not found in $PATH docker-exec 失败:“cd”:$PATH 中找不到可执行文件 - docker-exec failed: "cd": executable file not found in $PATH docker-compose无法启动服务:“ exec:\\” python3 \\”:找不到可执行文件 - docker-compose cannot start service: “exec: \”python3\": executable file not found Docker 映像在 docker 运行时正常启动,但在 docker-compose 失败时出现“$PATH 中找不到可执行文件:未知”错误 - Docker image starts fine with docker run but fails with docker-compose with “executable file not found in $PATH: unknown” error Docker – exec: "bash": $PATH 中找不到可执行文件 - Docker – exec: "bash": executable file not found in $PATH 在 $PATH 中找不到 Docker 撰写可执行文件”:未知 - Docker compose executable file not found in $PATH": unknown Docker 撰写:$PATH 中未找到可执行文件:未知 - Docker Compose: executable file not found in $PATH: unknown docker-compose 构建失败,未找到文件但文件实际存在 - docker-compose build failed, file not found but file actually exist docker-compose exec导致[Errno 2]没有此类文件或目录:docker容器中的'docker-compose':'docker-compose' - docker-compose exec causes [Errno 2] No such file or directory: 'docker-compose': 'docker-compose' in docker container Docker/Angular/Nginx:“exec:\\”npm\\“:在 $PATH 中找不到可执行文件”: - Docker/Angular/Nginx: “exec: \”npm\“: executable file not found in $PATH”:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM