繁体   English   中英

Docker 不运行入口点脚本

[英]Docker doesn't run entrypoint script

不明白为什么 Docker 会忽略我的 docker-endpoint.sh

文件

FROM php:7.1-apache

RUN a2enmod rewrite expires

RUN set -ex \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        libjpeg-dev \
        libpng-dev \
        libcurl4-openssl-dev \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
    && docker-php-ext-install opcache gd pdo_mysql zip

WORKDIR /var/www/html

COPY config/php/php.ini /usr/local/etc/php/
COPY docker-entrypoint.sh /usr/local/bin/

RUN set -xe \
    chown -R www-data:www-data . \
    && chmod +x /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["apache2-foreground"]

docker-entrypoint.sh

#!/bin/bash

set -e

echo "Hello"

exec "$@"

我希望看到“你好”。 容器正常启动,没有错误,但是Apache不工作。 安装了 Bash。 我还尝试用 #!/bin/sh 替换 #!/bin/bash 甚至删除它 - 结果相同。

更新。 配置文件

[PHP]

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 256M

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 10M

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 10M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = Off

[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1

; The OPcache shared memory storage size.
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
opcache.revalidate_freq=2

; If enabled, a fast shutdown sequence is used for the accelerated code
opcache.fast_shutdown=1

我使用了您的 Dockerfile 和端点,并在进行一次修改后运行了两个命令(注释掉 php.ini 副本)

docker build . -t me/foo
docker run me/foo

镜像构建成功,容器启动成功,控制台显示Hello 我不认为 ENTRYPOINT 是一个问题。

我会检查你的 php.ini 文件。

如果您可以将其发布在原始问题中,并在添加时在我的答案中添加评论,我将很乐意再次查看。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM