1

Im new to docker and tried a few different setups in my Dockerfile and it works great. Now when I try to use apt-get install inside my docker file (docker build .) it just breaks and I get the following error:

=> ERROR [ 6/14] RUN apt-get install -y php8.0-gd
------                                                                                                 
 > [ 6/14] RUN apt-get install -y php8.0-gd:                                                           
#11 0.213 Reading package lists...                                                                     
#11 0.670 Building dependency tree...
#11 0.767 Reading state information...
#11 0.846 E: Unable to locate package php8.0-gd
#11 0.846 E: Couldn't find any package by glob 'php8.0-gd'
#11 0.846 E: Couldn't find any package by regex 'php8.0-gd'

I've tried to change to other apt-get install packages but same result no matter what package I try to install. I've also tried to install all packages in one RUN command, bud rewrote the code as shown below, to see if it was one specific package that crashed it.

Here is my code:

FROM php:8.0-apache-buster

RUN mkdir /workdir

WORKDIR /workdir

COPY . .

RUN apt-get update -y
RUN apt-get install -y php8.0-gd
RUN apt-get install -y php8.0-imagick
RUN apt-get install -y php8.0-pgsql
RUN apt-get install -y php-gettext
RUN apt-get install -y php8.0-curl
RUN apt-get install -y php8.0-soap
RUN apt-get install -y php-bcmath
RUN apt-get install -y language-pack-ko-base
RUN a2enmod rewrite

EXPOSE 80

CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]

I've searched and search but cannot find someone with the same problem. I am really new to Docker and I havn't figgured out if it is better to set this up in the docker-composer.yml file?

  • It seems that's Debian issue because your packages are valid and correct names in Debian Repos. I think you can for now manually `wget` or `curl` `.deb` files and install them. – Saeed Mar 28 '21 at 07:32
  • Ok. Can you please provide a code example? – Samuel Sylvander Mar 29 '21 at 06:52
  • I've dug into it more, checking all packages when you run `apt update`, but there's no package called `php8.0-gd` in packages. Although it exists https://packages.debian.org/sid/php8.0-gd but it's not in http://ftp.debian.org/debian/dists/buster/main/binary-amd64/. You can download `Packages.gz` and `gunzip` it wherever, then open and find `php8.0-gd`. – Saeed Mar 29 '21 at 10:10
  • My comment may be incorrect, but that's my findings and deep searching. Why don't you use `alpine` or `ubuntu` image and build and install php for yourself with required configs? That's the hard-way but I think it could be an alternative – Saeed Mar 29 '21 at 10:11
  • I will actually do that Saeed. Was just surprised that this didn't work as expected. I've made a similar setup with ubuntu and it works perfect. Just don't like it when I don't understand why things don't work. – Samuel Sylvander Mar 30 '21 at 12:58
  • That's because `ubuntu` and `debian` repos are different, Ubuntu's repos are from `ubuntu.com` and Debian's are `debian.org`. I recommend you if you insist on using Debian base image, tell Debian team regarding this one or ask in https://superuser.com/ or somewhere else. Also I appreciate if you comment me here when you've found the solution:) – Saeed Mar 30 '21 at 13:48

1 Answers1

0

Please try this

FROM php:8.0-apache-buster

RUN mkdir /workdir

WORKDIR /workdir

COPY . .

RUN apt-get -y update && apt-get upgrade 
RUN apt-get install -y lsb-release ca-certificates apt-transport-https software-properties-common
RUN apt-get install -y php8.0-gd php8.0-imagick php8.0-pgsql php-gettext php8.0-curl php8.0-soap php-bcmath language-pack-ko-base
RUN a2enmod rewrite

EXPOSE 80

CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]

Please refer this SO thread about using RUN multiple lines.

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
  • 1
    If you're going to combine the `apt-get install` lines together, it is specifically important to `RUN apt-get update && apt-get install` in a single command (if `apt-get update` hits the Docker layer cache but `apt-get install doesn't`, the old cached package index might point to URLs that don't exist any more). But otherwise this answer just seems to be "run `apt-get upgrade` first"; should that make a difference? – David Maze Mar 28 '21 at 11:01
  • I did the RUN apt-get upgrade -y before RUN apt-get -y update but same error. – Samuel Sylvander Mar 29 '21 at 03:32