Docker bash文件将不会加载

时间:2018-10-19 08:31:40

标签: bash reference docker-compose containers

我是Docker的新手,我尝试构建一个php-fpm容器,其中也应包含sendmail

具有以下配置

# php-fpm
FROM php:7.2-fpm

RUN apt-get update && apt-get install -y sendmail sendmail-bin mailutils openssl git libcurl4-gnutls-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev zlib1g-dev libicu-dev g++ libxml2-dev libpq-dev \
 # && git clone -b php7.2 https://github.com/phpredis/phpredis.git /usr/src/php/ext/redis \
 && docker-php-ext-install pdo pdo_mysql pdo_pgsql pgsql intl curl json opcache xml zip mysqli mbstring \
 && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
 && docker-php-ext-install -j$(nproc) gd \
 && apt-get autoremove && apt-get autoclean \
 && rm -rf /var/lib/apt/lists/* \

RUN yes | pecl install xdebug \

# configure sendmail
COPY ./*.sh /usr/local/bin/
COPY ./php_mail.ini /usr/local/etc/php/conf.d/mail.ini
RUN chmod a+x /usr/local/bin/*.sh
ENTRYPOINT ["start_sendmail_mta.sh"]

RUN update-ca-certificates

ENV PHP_DATE_TIMEZONE="Europe/Berlin" \
    PHP_LOG_ERRORS_MAX_LEN=1024 \
    PHP_LOG_ERRORS="" \
    PHP_MAX_EXECUTION_TIME=0 \
    PHP_MAX_FILE_UPLOADS=20 \
    PHP_MAX_INPUT_VARS=1000 \
    PHP_MEMORY_LIMIT=128M \
    PHP_POST_MAX_SIZE=8M \
    #PHP_SENDMAIL_PATH="/usr/sbin/sendmail -t -i" \
    PHP_SESSION_SAVE_HANDLER=files \
    PHP_SESSION_SAVE_PATH="" \
    PHP_UPLOAD_MAX_FILESIZE=2M \
    PHP_XDEBUG_DEFAULT_ENABLE=0 \
    PHP_XDEBUG_IDEKEY=''\
    PHP_XDEBUG_PROFILER_ENABLE=0 \
    PHP_XDEBUG_REMOTE_AUTOSTART=0 \
    PHP_XDEBUG_REMOTE_CONNECT_BACK=0 \
    PHP_XDEBUG_REMOTE_ENABLE=0 \
    PHP_XDEBUG_REMOTE_HOST=0

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
    && php -r "unlink('composer-setup.php');"

CMD ["php-fpm"]

EXPOSE 9000

运行docker-compose build时出现以下错误

 Service 'php-fpm' failed to build: The command '/bin/sh -c chmod a+x /usr/local/bin/*.sh' returned a non-zero code: 1

enter image description here

[![在此处输入图片描述] [2]] [2]

为什么在这种情况下找不到bash文件?

chmod: cannot access '/usr/local/bin/*.sh': No such file or directory
ERROR: Service 'php-fpm' failed to build: The command '/bin/sh -c chmod a+x /usr/local/bin/*.sh' returned a non-zero code: 1

如果我运行RUN ls -l /usr/local/bin,我将看不到任何bash文件

1 个答案:

答案 0 :(得分:0)

只需将副本./*.sh更改为:

COPY sendmail.sh /usr/local/bin/
COPY ./php_mail.ini /usr/local/etc/php/conf.d/mail.ini
COPY start_sendmail_mta.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/*.sh