无法建立php docker映像

时间:2020-08-14 09:53:58

标签: php docker docker-compose dockerfile docker-container

构建docker php映像时出现此错误

步骤13/25:添加php.ini /usr/local/etc/php/php.ini

错误:服务'phpt3'生成失败:添加失败:统计 /var/lib/docker/tmp/docker-builder310748204/php.ini:否 这样的文件或目录

以下是docker文件:

FROM php:7.3-fpm

# install the PHP extensions we need
RUN apt-get update \
    && apt-get install -y --no-install-recommends msmtp mailutils vim curl debconf subversion git apt-transport-https apt-utils \
    build-essential locales acl mailutils wget nodejs \
    gnupg gnupg1 gnupg2 \
    zlib1g-dev zlib1g-dev libicu-dev g++ \
    sudo

# Install GD
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
RUN docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd

# MYSQLI 
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

# Install ext-zip
RUN apt-get install -y unzip libzip-dev
RUN docker-php-ext-install zip

RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo_mysql json calendar intl

ADD php.ini /usr/local/etc/php/php.ini
COPY additionnal.ini /usr/local/etc/php/conf.d/

COPY php-fpm-pool.conf  /usr/local/etc/php/pool.d/www.conf

RUN rm -rf /var/lib/apt/lists/* \
    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen && \
    locale-gen

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version

# set up sendmail config, see http://linux.die.net/man/5/ssmtp.conf for options
RUN echo "hostname=localhost.localdomain" > /etc/msmtp/msmtp.conf
RUN echo "mailhub=maildevt3" >> /etc/msmtp/msmtp.conf
# The above 'maildevt3' is the name you used for the link command
# in your docker-compose file or docker link command.
# Docker automatically adds that name in the hosts file
# of the container you're linking MailDev to.

# Set up php sendmail config
RUN echo "sendmail_path=sendmail -i -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini

# Fully qualified domain name configuration for sendmail on localhost.
# Without this sendmail will not work.
# This must match the value for 'hostname' field that you set in ssmtp.conf.
RUN echo "localhost localhost.localdomain" >> /etc/hosts 

WORKDIR /var/www/

EXPOSE 9000
CMD ["php-fpm"]

任何人都可以帮助我克服此错误。

我正在做本教程 https://passions.miary.dev/2019/08/30/docker-maildev-fr/

1 个答案:

答案 0 :(得分:1)

图像安装程序似乎无权写入安装目录。

->如何解决:

  1. ADD failed : No such file/Directory while building docker image
  2. 如果这样不起作用:请检查错误中显示的文件夹是否存在。
  3. 使用chmod-> https://wiki.ubuntuusers.de/chmod/
  4. 授予目录足够的权限