I'm using docker for my Laravel project. But I'm having an error installing PHP.
I had already run the project once with this same configuration and had no problems.
Error:
=> ERROR [14/26] RUN apt-get install -y php8.1-fpm php8.1-common php8.1-curl php8.1-mysql php8.1-mbstring php8.1-xml php8.1-bcmath php8.1-gd php8.1-xdebug php8.1-soap php8 2.3s
------
> [14/26] RUN apt-get install -y php8.1-fpm php8.1-common php8.1-curl php8.1-mysql php8.1-mbstring php8.1-xml php8.1-bcmath php8.1-gd php8.1-xdebug php8.1-soap php8.1-zip:
#18 0.621 Reading package lists...
#18 1.822 Building dependency tree...
#18 2.008 Reading state information...
#18 2.106 Some packages could not be installed. This may mean that you have
#18 2.106 requested an impossible situation or if you are using the unstable
#18 2.106 distribution that some required packages have not yet been created
#18 2.106 or been moved out of Incoming.
#18 2.106 The following information may help to resolve the situation:
#18 2.106
#18 2.106 The following packages have unmet dependencies:
#18 2.255 php8.1-fpm : Depends: systemd but it is not going to be installed or
#18 2.255 systemd-tmpfiles but it is not installable
#18 2.275 E: Unable to correct problems, you have held broken packages.
------
executor failed running [/bin/sh -c apt-get install -y php8.1-fpm php8.1-common php8.1-curl php8.1-mysql php8.1-mbstring php8.1-xml php8.1-bcmath php8.1-gd php8.1-xdebug php8.1-soap
php8.1-zip]: exit code: 100
My Dockerfile:
#------------- Setup Environment -------------------------------------------------------------
# Pull base image
FROM ubuntu:18.04
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install common tools
RUN apt-get update
RUN apt-get install -y wget curl nano htop git unzip bzip2 software-properties-common locales
# Set evn var to enable xterm terminal
ENV TERM=xterm
# Set working directory
WORKDIR /var/www/html
COPY . ./
# Add repositories
RUN LC_ALL=C.UTF-8 apt-add-repository ppa:ondrej/php
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
RUN echo "deb http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list
RUN echo "deb-src http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list
RUN apt-get update
#------------- Application Specific Stuff ----------------------------------------------------
# Install PHP
RUN apt-get update
RUN apt-get install -y \
php8.1-fpm \
php8.1-common \
php8.1-curl \
php8.1-mysql \
php8.1-mbstring \
php8.1-xml \
php8.1-bcmath \
php8.1-gd \
php8.1-xdebug \
php8.1-soap \
php8.1-zip
RUN echo "xdebug.mode=develop" >> /etc/php/8.1/mods-available/xdebug.ini
#------------- FPM & Nginx configuration ----------------------------------------------------
# Config fpm to use TCP instead of unix socket
ADD docker/www.conf /etc/php/8.1/fpm/pool.d/www.conf
RUN mkdir -p /var/run/php
# Install Nginx
RUN apt-get install -y nginx
ADD docker/game /etc/nginx/sites-enabled/
ADD docker/nginx.conf /etc/nginx/
#------------- Composer & laravel configuration ----------------------------------------------------
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#------------- Supervisor Process Manager ----------------------------------------------------
# Install supervisor
RUN apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
ADD docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
#------------- Container Config ---------------------------------------------------------------
ARG ENV_KEY=dev
COPY ./.${ENV_KEY}.env ./.env
RUN chown -R www-data:www-data ./
# Expose port 80
EXPOSE 80
# Set supervisor to manage container processes
ENTRYPOINT ["/usr/bin/supervisord"]
I already cleared the docker settings with docker system prune -a
. I've also uninstalled and installed docker.
Any suggestions on how I can resolve the issue?
CodePudding user response:
I have the same problem since August 2, looks like something wrong with ondrej/php
repository.
First, I tried to install systemd
as @matiaslauriti suggested, but the following error has occured:
The following packages have unmet dependencies:
[07:33:33]#24 7.480 systemd : Depends: libsystemd0 (= 237-3ubuntu10.53) but 237-3ubuntu10.54 is to be installed
That problem has been fixed by adding the following to sources.list
:
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic-proposed main" >> /etc/apt/sources.list
You don't need install systemd
explicitly, it will be installed as one of php
dependency.