skip to Main Content

I have a website running on the official PHP docker image (https://hub.docker.com/_/php) using php7.4-apache.

I can’t upgrade to PHP 8 at this stage, so I would like to stick to this setup as much as possible for now. This image ships with Apache 2.4.48 and I need to install the latest version to patch existing security issues.

I haven’t seen this documented anywhere. This is where I got up to:

FROM php:7.4-apache

RUN apt-get -y update
RUN apt-get install software-properties-common -y
RUN apt-get install -y gnupg
RUN apt-get install -y ca-certificates
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys  4F4EA0AAE5267A6C

RUN add-apt-repository ppa:ondrej/apache2 -y && sudo apt update

Note that I tried with and without the apt-key line, and I end up with :

Step 6/27 : RUN add-apt-repository ppa:ondrej/apache2 -y && sudo apt update
 ---> Running in 9fa3694a2c5b
gpg: keybox '/tmp/tmpzx1fa6uo/pubring.gpg' created
gpg: /tmp/tmpzx1fa6uo/trustdb.gpg: trustdb created
gpg: key 4F4EA0AAE5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
gpg: no valid OpenPGP data found.
/bin/sh: 1: sudo: not found

Update:
After removing sudo, I got this error

Hit:1 deb.debian.org/debian bullseye InRelease 
Get:3 security.debian.org/debian-security bullseye-security InRelease [44.1 kB] 
Ign:4 ppa.launchpad.net/ondrej/apache2/ubuntu jammy InRelease 
Err:6 ppa.launchpad.net/ondrej/apache2/ubuntu jammy Release 404 Not Found 
[IP: 91.189.95.85 80] Reading package lists... 
E: The repository 'ppa.launchpad.net/ondrej/apache2/ubuntu jammy Release' does not have a Release file.

Any help would be much appreciated!

2

Answers


  1. Chosen as BEST ANSWER

    I found a solution to my problem here: https://gist.github.com/ianacid/4ee1b2b7705efc6aba25ab2f3976f62f

    We first load new sources:

    # deb http://snapshot.debian.org/archive/debian/20210621T000000Z buster main
    deb http://deb.debian.org/debian buster main
    # deb http://snapshot.debian.org/archive/debian-security/20210621T000000Z buster/updates main
    deb http://security.debian.org/debian-security buster/updates main
    # deb http://snapshot.debian.org/archive/debian/20210621T000000Z buster-updates main
    deb http://deb.debian.org/debian buster-updates main
    deb http://ftp.ch.debian.org/debian sid main
    

    Copy them in the docker image and run updates:

    COPY ./sources.list /etc/apt/sources.list  
    
    RUN apt-get update && apt-get install apache2 -y
    

  2. In the last line you are using sudo which isn’t installed by default. Removing it should solve your error. Your Dockerfile would look like this.

    FROM php:7.4-apache
    
    RUN apt-get -y update
    RUN apt-get install software-properties-common -y
    RUN apt-get install -y gnupg
    RUN apt-get install -y ca-certificates
    #RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys  4F4EA0AAE5267A6C
    
    RUN add-apt-repository ppa:ondrej/apache2 -y && apt update
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search