未明确调用时,Docker容器映像中的二进制文件未启动

时间:2022-02-19 16:05:42

I'm building my own Dockerfile with official images as it's base which I'm adjusting with Ansible for simple configuration changes. Relevant portion of the dockerfile:

我正在使用官方图像构建我自己的Dockerfile,因为它是我用Ansible进行简单配置更改的基础。 dockerfile的相关部分:

FROM php:7.0-fpm
MAINTAINER hyperfocus

# Ansible cmds

EXPOSE 9000
CMD [“php-fpm”]

Whenever the image is built and I try to start it with docker run php_fpm_prod:v0.1 it gives me the error: /bin/sh: 1: [“php-fpm”]: not found.

每当构建映像并尝试使用docker run php_fpm_prod:v0.1启动它时它会给出错误:/ bin / sh:1:[“php-fpm”]:找不到。

But whenever I try to start it with docker run php_fpm_prod:v0.1 php-fpm it starts succesfully:

但每当我尝试使用docker启动它时,运行php_fpm_prod:v0.1 php-fpm它会成功启动:

[03-Nov-2015 10:24:38] NOTICE: fpm is running, pid 1
[03-Nov-2015 10:24:38] NOTICE: ready to handle connections

How can I make docker run php_fpm_prod:v0.1 behave like docker run php_fpm_prod:v0.1 php-fpm?

如何使docker运行php_fpm_prod:v0.1表现得像docker run php_fpm_prod:v0.1 php-fpm?

Thanks.

谢谢。

1 个解决方案

#1


1  

The CMD of a php fpm Dockerfile is already CMD ["php-fpm"] (overriding the debian-jessie CMD), so you shouldn't need to specify it again.

php fpm Dockerfile的CMD已经是CMD [“php-fpm”](覆盖了debian-jessie CMD),所以你不需要再次指定它。

Those debian or php fpm Dockerfile don't define an ENTRYPOINT which means thedefault one applies /bin/sh -c.

那些debian或php fpm Dockerfile没有定义ENTRYPOINT,这意味着默认值为/ bin / sh -c。

First, make sure, as in "Dockerfile CMD command not found" to use the right quotes:

首先,确保在“找不到Dockerfile CMD命令”中使用正确的引号:

CMD ["php-fpm"]

(Or don't specify the CMD at all, since it will be inherited from the base image)

(或者根本不指定CMD,因为它将从基础图像继承)

#1


1  

The CMD of a php fpm Dockerfile is already CMD ["php-fpm"] (overriding the debian-jessie CMD), so you shouldn't need to specify it again.

php fpm Dockerfile的CMD已经是CMD [“php-fpm”](覆盖了debian-jessie CMD),所以你不需要再次指定它。

Those debian or php fpm Dockerfile don't define an ENTRYPOINT which means thedefault one applies /bin/sh -c.

那些debian或php fpm Dockerfile没有定义ENTRYPOINT,这意味着默认值为/ bin / sh -c。

First, make sure, as in "Dockerfile CMD command not found" to use the right quotes:

首先,确保在“找不到Dockerfile CMD命令”中使用正确的引号:

CMD ["php-fpm"]

(Or don't specify the CMD at all, since it will be inherited from the base image)

(或者根本不指定CMD,因为它将从基础图像继承)