Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 432
Chris Avatar asked Nov 04 '25 00:11

Chris


2 Answers

Here is what I had to do starting from Ubuntu Stretch, I changed:

FROM ubuntu

In order to get pass the tzdata prompt, insert the environment variable before the apt-get line (edit use ARG instead of ENV so that it only applies to the docker build and not when the container is running):

ARG DEBIAN_FRONTEND=noninteractive

Then you need to apt-get all these packages:

RUN apt-get update && apt-get install -y --no-install-recommends \
wget gpg dirmngr gpg-agent build-essential checkinstall tk-dev \
libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev \
libgdbm-dev libc6-dev libbz2-dev

I also needed to add the --no-check-certificate option in all the wget calls.

like image 146
kamion Avatar answered Nov 06 '25 13:11

kamion


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

like image 29
Chris Avatar answered Nov 06 '25 15:11

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!