docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.81k stars 2k forks source link

apt-get install did not complete successfully: exit code: 100 #1423

Closed DylanSS98 closed 1 year ago

DylanSS98 commented 1 year ago

Hi,

I need to install packages on my container. Before this Dockerfile worked but now i have this error when run my build :

failed to solve: process "/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libonig-dev curl npm" did not complete successfully: exit code: 100

does anyone have this problem too ? here is my DockerFile :

FROM php:8.0-apache

WORKDIR /var/www/html

ENV APACHE_DOCUMENT_ROOT=/var/www/html/public

RUN apt-get update && \
    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libonig-dev curl npm

RUN npm install npm@latest -g && \
    npm install n -g && \
    n latest

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN a2enmod rewrite

RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && \
   mv composer.phar /usr/local/bin/composer \

RUN npm install npm@latest -g && \
    npm install n -g && \
    n latest

RUN docker-php-ext-install mysqli pdo pdo_mysql exif mbstring

# Réécriture d'urls apache
RUN a2enmod rewrite
shatsar commented 1 year ago

Hello, I had the same issue. In my case, it was related to images based on debian bookworm with docker 20.10.8

I found two ways to solve it:

1) use bullseye I changed

FROM php:8.2-apache

(in the logs you'll see it is using bookworm) to

FROM php:8.2-apache-bullseye

2) upgrade docker After finding this answer on SO: https://stackoverflow.com/questions/76491765/docker-buildx-failing-with-problem-executing-scripts-aptupdatepost-invoke/76514507#76514507 I noticed my docker version was old. I changed the source of my docker installation, updated it and now with Docker version 24.0.4 my docker file is working again with bookworm

DylanSS98 commented 1 year ago

thx @shatsar for your response.

I was able to solve my problem by modifying the syntax of my Dockerfile. Now everything is okay, and I'm sharing it to help other people who might have the same issue.

FROM php:8.0-apache

RUN apt-get update && \
    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libonig-dev && \
    apt-get install -y npm

RUN docker-php-ext-install mysqli pdo pdo_mysql exif mbstring

# Installation de Composer
RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && \
    mv composer.phar /usr/local/bin/composer

WORKDIR /var/www/html

ENV APACHE_DOCUMENT_ROOT=/var/www/html/public

# Configuration d'Apache
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
    sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
    a2enmod rewrite

# Installation des packages npm
RUN npm install