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

  apt-get, docker, dockerfile

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 buster/updates InRelease [65.4 kB]
Get:2 buster InRelease [121 kB]
Get:3 buster-updates InRelease [51.9 kB]
Get:4 buster/updates/main amd64 Packages [268 kB]
Get:5 buster/main amd64 Packages [7907 kB]
Get:6 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?

Source: Docker Questions