简体   繁体   English

以字符串形式运行命令时,Docker exec错误“在$ PATH中找不到可执行文件:未知”

[英]Docker exec error “executable file not found in $PATH”: unknown" when running a command as a string

Below is the command I am trying to run: 以下是我尝试运行的命令:

docker exec sandbox_1 'influxd-ctl sandbox_1:8091'

I understand that apparently this means the container will execute it with a different shell that does have the necessary $PATH but I'm not sure how to deal with that. 我知道显然这意味着容器将使用确实具有必要的$PATH的其他外壳执行它,但是我不确定如何处理。

For what it's worth, I tried influxd-ctl without the single quotes and it didn't read the rest of the command. 对于它的价值,我尝试了不带单引号的influxd-ctl ,但没有读取命令的其余部分。

docker exec sandbox_1 influxd-ctl sandbox_1:8091

Thoughts? 思考?

Update: I also tried running bash -c <string> as the command I passed to exec but that didn't seem to work either. 更新:我也尝试运行bash -c <string>作为传递给exec的命令,但这似乎也不起作用。

Single quotes shouldn't be used. 不应使用单引号。 The Exec Command takes the command and it's arguments as separate arguments. Exec命令将命令及其参数作为单独的参数。

The correct command in your case should be: 根据您的情况,正确的命令应为:

docker exec <container> influxd-ctl <container>:8091

You can also test the command when having a shell inside the container like this: 您还可以在容器内有外壳时测试命令,如下所示:

docker exec -it <container> bash

You should then (provided bash is available inside the container, otherwise other shells can be used instead) get a root shell like this: 然后,您应该(提供的bash在容器内可用,否则可以使用其他shell)获得如下所示的根shell:

root@<container>:~# 

Note: The working dir might be different based on where it was set in the Dockerfile used to build the image of the container. 注意:根据在用于构建容器映像的Dockerfile中设置的位置,工作目录可能会有所不同。

In the now interactive shell talking to the container, you can try your command explicitly without the Exec command passing stuff around. 在与容器进行交互的交互式外壳中,您可以显式地尝试命令,而无需Exec命令来回传递东西。

root@<container>:~# influxd-ctl <container>:8091

If you find that your command doesn't work there, then probably the influxd-ctl command expects different parameters from what you are suggesting. 如果发现您的命令在那里不起作用,则可能influxd-ctl命令期望使用与您建议的参数不同的参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 docker exec 运行命令时,“sqlplus”:在 $PATH 中找不到可执行文件 - "sqlplus": executable file not found in $PATH" when running a command with docker exec 运行 docker 容器时出错:启动容器进程导致“exec:\”python\“:在 $PATH 中找不到可执行文件”:未知 - Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown exec:“docker-runc”:在$ PATH中找不到可执行文件:未知 - exec: “docker-runc”: executable file not found in $PATH: unknown 尝试详细运行docker容器或docker exec时,在$ PATH中找不到错误可执行文件 - Getting error executable file not found in $PATH when trying verbose run docker container or when docker exec 运行 ruby​​ 测试时,在 $PATH 中找不到 Jenkinsfile docker exec 错误可执行文件 - Jenkinsfile docker exec error executable file not found in $PATH while running ruby tests exec: \\“mysql\\”: 在 $PATH 中找不到可执行文件&quot;: 未知 - exec: \“mysql\”: executable file not found in $PATH": unknown 收到错误“”exec:\“python2\”:$PATH“中找不到可执行文件:未知。” 尝试以交互方式运行容器时 - Getting the error “”exec: \“python2\”: executable file not found in $PATH“: unknown.” when trying to run container interactively Docker – exec: "bash": $PATH 中找不到可执行文件 - Docker – exec: "bash": executable file not found in $PATH Docker,\\“ping\\”:在 $PATH 中找不到可执行文件”:未知 - Docker, \“ping\”: executable file not found in $PATH": unknown 在 $PATH 中找不到 Docker 撰写可执行文件”:未知 - Docker compose executable file not found in $PATH": unknown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM