$ PATH中找不到可执行文件 [英] Executable file not found in $PATH

查看:777
本文介绍了$ PATH中找不到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PHP-FPM 7.1的Docker文件中工作。我正在结束Dockerfile与以下行:

  CMD [php71-php-fpm] 

因为我使用 docker-compose 这是我如何启动容器:

  docker-compose up -d 

容器按照以下方式编译好(显然):

 成功构建014e24455b53 
警告:服务php的图像已建立,因为它不存在。要重建此图像,您必须使用'docker-compose build'或'docker-compose up --build'。
创建php71-fpm

但是结束时出现以下错误:

 错误:对于php无法启动服务php:无效的头字段值oci运行时错误:container_linux.go:247:启动容器进程导致\ exec:\\\php71-php-fpm\\\:$ PATH\\\\
中找不到可执行文件
错误:在启动项目时遇到错误。

我尝试过以下操作:

  CMD php71-php-fpm 

错误消失,具有代码127的容器出口:

 > docker-compose ps 
名称命令状态端口
---------------------------------- ---------------------
php71-fpm / bin / sh -c php71-php-fpm退出127

我在这里缺少什么?



更新 / p>

我已经找到以下答案此处


当您的PATH系统变量中没有找到给定的命令
时,/ bin / sh返回值127,它不是内置的,在shell
命令中。换句话说,系统不明白你的命令
,因为它不知道在哪里找到你要
调用的二进制。




这让我觉得文件 php71-paths.sh 没有被执行,所以路径设置不正确。



再次,我失踪了?



这个 php71-fpm 将与另一个运行Nginx的容器链接(这是一个WIP,我学习Docker的方式)



这里是完整的 Dockerfile ,让您看看。

解决方案

我相信你遇到麻烦,因为由Docker运行的默认shell不是根据这个答案,这意味着脚本在 /etc/profile.d / don'被处理。



如果您需要个人资料处理,请尝试将最后一行更改为 CMD [/ bin / sh,-l,-c ,php71-php-fpm] 来调用登录shell。


I am working in a Dockerfile for PHP-FPM 7.1. I am ending the Dockerfile with the following line:

CMD ["php71-php-fpm"]

Because I am using docker-compose this is how I start up the container:

docker-compose up -d

The container compiles fine (apparently) as per this lines:

Successfully built 014e24455b53
WARNING: Image for service php was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating php71-fpm

But it ends with the following error:

ERROR: for php  Cannot start service php: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"php71-php-fpm\\\": executable file not found in $PATH\"\n"
ERROR: Encountered errors while bringing up the project.

I have tried the following:

CMD php71-php-fpm

And the error disappear but then the container exit with code 127:

> docker-compose ps
  Name              Command             State     Ports
-------------------------------------------------------
php71-fpm   /bin/sh -c php71-php-fpm   Exit 127

What I am missing here?

UPDATE

I have found the following answer here:

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

Which makes me think that the file php71-paths.sh is not being executed so the paths are not setup properly.

Once again, what I am missing?

This php71-fpm will be linked with another container running Nginx (this is a WIP and my way to learn Docker)

Here it's the complete Dockerfile for you to take a look.

解决方案

I believe you're running into trouble because the default shell run by Docker is not a login shell according to this answer, which means scripts in /etc/profile.d/ don't get processed.

If you need profile processing, try changing your last line to CMD ["/bin/sh", "-l", "-c", "php71-php-fpm"] to invoke a login shell.

这篇关于$ PATH中找不到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆