I'm running a Docker container and having trouble installing packages. I have tried various methods of fixing the issue after a few hours of Googling but nothing seems to be working. I don't understand enough about Linux to figure out what is going wrong.

Specifically I am trying to install the package php-common with apt-get and I keep getting E: Package 'php-common' has no installation candidate response. This response happens for a lot of packages I try to install though and I don't know why.

The Docker image I am using the official php image php7.1-apache, based on Debian 10 (Buster).

Running uname -a prints: Linux 1fa97a139193 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 GNU/Linux

This is the contents of my /etc/apt/sources.list file:

# deb http://snapshot.debian.org/archive/debian/20190910T000000Z buster main
deb http://deb.debian.org/debian buster main
# deb http://snapshot.debian.org/archive/debian-security/20190910T000000Z buster/updates main
deb http://security.debian.org/debian-security buster/updates main
# deb http://snapshot.debian.org/archive/debian/20190910T000000Z buster-updates main
deb http://deb.debian.org/debian buster-updates main

Output of cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION="10 (buster)"

Output of cat /etc/issue

Debian GNU/Linux 10 \n \l
  • Hello and welcome to the Unix and Linux stack exchange site! Please review the Help Center for more information on how to use this site. To get to your question, could you please edit your post to include the following details to clarify your post: What is the output of cat /etc/os-release or cat /etc/issue? What is the results of apt-cache search php-common? Please run these commands from within your container. Thank you. – kemotep Sep 20 '19 at 16:04
  • Hi, thanks for the response. I edited the post to include the output of cat /etc/os-release and cat /etc/ – Marcus Horne Sep 21 '19 at 17:43
  • Running apt-cache search php-common prints nothing – Marcus Horne Sep 21 '19 at 17:46

I don’t know where the php7.1-apache image is hosted, so I wasn’t able to check with that; but I suspect that your problem stems from the fact that the majority of Debian-based images ship with no repository indexes, so apt-get install won’t work initially.

One of the first steps when using such a container is to run apt-get update. Once that’s done, apt-get install should work, assuming the packages you want are available in the configured repositories.

Regarding your sources.list, if you’re trying to install packages from Debian 10, I highly recommend starting with a Debian 10-based image rather than an image based on an older release. You could start with debian:10...

  • Hey, I tried running apt-get update already. It did fix a previous issue, but not this one unfortunately – Marcus Horne Sep 21 '19 at 17:40
  • Also I am running buster, my mistake, I included more information above. – Marcus Horne Sep 21 '19 at 17:47
  • @Jasen sorry, I misread your comment earlier; my last paragraph was based on the mention in the original question that the image was based on Jessie. – Stephen Kitt Sep 22 '19 at 16:52
  • @Marcus that’s rather odd! If apt-get update completed without error, apt-get install php-common should work just fine — php-common is present in Debian 10. – Stephen Kitt Sep 22 '19 at 16:53
  • @StephenKitt Yeah I thought it was pretty strange. Do I maybe have the wrong repo URL? http://deb.debian.org/debian?? – Marcus Horne Sep 22 '19 at 17:51

This is intentional, as stated in "E: Package 'php-XXX' has no installation candidate".

The proper solution to this error is to either use FROM debian:XXX and install Debian's PHP packages directly, or to use docker-php-ext-install, pecl, and/or phpize to install the necessary additional extensions and utilities.

New contributor
phy25 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.