Search code examples
pythondockertzdata

How to build the docker python container with ubuntu 18.04 (bionic)?


Python provides docker images (https://hub.docker.com//python/), which come in a variety of flavours (based on different images from: https://hub.docker.com//buildpack-deps/). Unfortunately, none are provided with ubuntu 18.04 (bionic) as a base. I would like to build that.

I initially thought I should just start off with a "real" ubuntu 18.04 docker image (https://hub.docker.com/r/library/ubuntu/) and install relevant the ubuntu packages, but the resulting docker image appears to get pretty large quickly and of course doesn't pull in the current python release (3.7.0).

Next, I tried to simply build the exact Dockerfile provided on docker hub (https://github.com/docker-library/python/blob/8601079d1f70b03c01408377716a3243ce75cec9/3.7/stretch/Dockerfile), but replace the FROM buildpack-deps:stretch with FROM buildpack-deps:bionic. Unfortunately, the build appears to require some sort of interactive selection of my region and I don't see how I can get around that (output below).

Any suggestions on how to pre-configure this build so it doesn't ask me for the region / how to disable that prompt?

I saw suggestions using expect, but no idea if that can easily be integrated into the docker build.

Docker build output

[...]
Setting up tzdata (2018d-1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area:

PS: Building the docker image with the original FROM buildpack-deps:stretch appears to work fine, so this interactive selection is something related to the bionic base.


Solution

  • In short: don't do it.

    I wasn't aware that Ubuntu (18.04) bionic was no longer based on Debian stretch, but is now actually based on Debian buster. So instead of trying to build this on top of ubuntu, I can also just build it on top of buster and simply use:

    FROM buildpack-deps:buster