M
M
MikUrrey2021-06-25 22:04:24
PHP
MikUrrey, 2021-06-25 22:04:24

Error building container during composer install?

Below is the contents of the Dockerfile, the bummer is on the line after the comment # Composer

FROM php:8.0-fpm

RUN apt-get update -y 
RUN apt-get install -y \
git \
curl \
libz-dev \
libcurl4-openssl-dev \
libxml2-dev \
libssl-dev \
libpng-dev \
libonig-dev \
libmpdec-dev \
libzip-dev \
libevent-dev \
libicu-dev


# PHP extension
RUN docker-php-ext-install intl
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-install pcntl
RUN docker-php-ext-install gd
RUN docker-php-ext-install sockets
RUN docker-php-ext-install zip
RUN pecl install igbinary && docker-php-ext-enable igbinary

# decimal
RUN docker-php-source extract \
    && git clone --branch 1.x-php8 --depth 1 https://github.com/zlodes/ext-decimal.git /usr/src/php/ext/decimal \
    && cd /usr/src/php/ext/decimal && git submodule update --init \
    && docker-php-ext-install decimal

# Redis
RUN pecl install redis-5.3.2  && docker-php-ext-enable redis


# MySQL
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install pdo_mysql

# php.ini
COPY ./php.ini /usr/local/etc/php/php.ini

# Composer
RUN curl -sS https://getcomposer.org/installer | php -- \
        --filename=composer \
        --install-dir=/usr/local/bin && \
        echo "alias composer='composer'" >> /root/.bashrc

CMD ["php-fpm", "-F"]

WORKDIR /var/www

EXPOSE 9000


Mistake:
/bin/sh: 1: sudo: not found
curl: (23) Failed writing body (0 != 16230)
ERROR: Service 'php' failed to build: The command '/bin/sh -c curl -sS https://getcomposer.org/installer | sudo php --         --filename=composer         --install-dir=/usr/local/bin &&         echo "alias composer='composer'" >> /root/.bashrc' returned a non-zero code: 127

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MikUrrey, 2021-06-26
@MikUrrey

The solution is: curl: (23) Failed writing body means that the program called "through the pipe" did not process the output from curl and crashed. If your case is 1 in 1, then, most likely, PHP is not configured correctly. In php.ini turn on display_errors = On and watch the output, PHP will tell you what's wrong.
In my case, this was not the case:

Fatal error: Directive 'track_errors' is no longer available in PHP in Unknown on line 0

Removed track_errors from php.ini and the container took off.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question