docker – 在$PATH中找不到可执行文件

我在
PHP-FPM 7.1的Dockerfile中工作.我用以下行结束Dockerfile:

CMD ["php71-php-fpm"]

因为我使用的是docker-compose,所以这就是我启动容器的方法:

docker-compose up -d

容器按照以下行编译得很好(显然):

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

但它以以下错误结束:

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.

我尝试过以下方法:

CMD php71-php-fpm

然后错误消失,然后容器退出代码127:

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

我在这里缺少什么?

UPDATE

我找到了以下答案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.

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

再一次,我错过了什么?

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

这是完整的Dockerfile供您查看.

最佳答案 我相信你遇到了麻烦,因为根据
this answer,Docker运行的默认shell不是登录shell,这意味着/etc/profile.d/中的脚本不会被处理.

如果您需要配置文件处理,请尝试将最后一行更改为CMD [“/ bin / sh”,“ – l”,“ – c”,“php71-php-fpm”]以调用登录shell.

点赞