How to apt-get install firefox on an openjdk:11 docker base image without "no installation candidate" error?

Viewed 7240

I am trying to create a docker image which includes an installed Firefox browser, using openjdk:11-slim or openjdk:11 as my base image.

This is a minimal reproducible example of my dockerfile:

FROM openjdk:11

RUN rm -rf /var/lib/apt/lists/* && \
    apt-get update && apt-get install -y --no-install-recommends firefox

Here is the output of running docker build .:

$ docker build -t testing/simpleopenjdkfirefox .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM openjdk:11
 ---> 1eec9f9fe101
Step 2/2 : RUN rm -rf /var/lib/apt/lists/* &&     apt-get update && apt-get install -y --no-install-recommends firefox
 ---> Running in da4e93ffe4a1
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7860 B]
Fetched 8422 kB in 2s (4114 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package firefox is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'firefox' has no installation candidate
The command '/bin/sh -c rm -rf /var/lib/apt/lists/* &&     apt-get update && apt-get install -y --no-install-recommends firefox' returned a non-zero code: 100

My reasons to believe that running apt-get install firefox should be possible are:

I've tried using the following base images:

  • openjdk:11-slim - my desired base image for what I'm working on
  • openjdk:11 - the full de facto openjdk image, should be the default working case
  • openjdk:11-buster - to see if Debian 10 would work

Why does the apt-get install fail in the docker build, but not in the Ubuntu CLI? Is the issue Linux OS compatibility or something else?

1 Answers

The firefox package is only available under the Debian Unstable Repository (codename "Sid"). Debian Stable only has firefox-esr. To include the Sid repository in the package index update, you must add deb http://deb.debian.org/debian/ unstable main contrib non-free as a repository source for apt.

echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
apt-get update
apt-get install -y --no-install-recommends firefox

If the Sid repository does not have an up-to-date version of Firefox, the next best place to check are the Firefox PPAs (Personal Package Archive) operated by the Mozilla team themselves. PPAs are just repositories, and are added the exact same way as the Sid repository above:

For example,

sudo add-apt-repository ppa:mozillateam/firefox-next
sudo apt-get update
Related