6

I have 2 dockerfiles:

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
    software-properties-common \
    python3
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get update && apt-get install -y \
    python3

The thing is: when I run the first of them (with docker build) the build process hangs on:

enter image description here

The software-properties-common package is asking me about the geographical area - I cannot provide any input, it is not allowed when building images, I suppose.

However, when I build the second dockerfile, this problem does not occur. I'm curious - why is that?

mnj
  • 2,539
  • 3
  • 29
  • 58

2 Answers2

5

Add the following line in your Dockerfile and build again.

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
ravikt
  • 952
  • 6
  • 15
  • Ok, but why the second dockerfile does work fine, without that env `DEBIAN_FRONTEND`? – mnj Jul 20 '20 at 11:23
  • By the way, do you mean that I should install that exact package "tzdata" or was it just an example of how to set `DEBIAN_FRONTED` and I should actually ignore "tzdata"? – mnj Jul 20 '20 at 11:32
  • @Loreno I tried to build images using both the Dockerfiles you provided, but I could not reproduce the error. My build was successful in both. In your case, the build using second Dockerfile might be working due to layers from the previous builds. – ravikt Jul 20 '20 at 11:46
  • I included the package tzdata because your docker build stops at configuring the time zone(tzdata). You can work without that as well. – ravikt Jul 20 '20 at 11:47
  • 1
    I used `RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y software-properties-common python3` and unfortunately that didn't help. I'm still being asked for geographical location – mnj Jul 23 '20 at 09:21
  • I also tried `RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y tzdata software-properties-common python3.7` - still, the same problem occurs :( – mnj Jul 23 '20 at 09:27
  • @Loreno can you share your Dockerfile? I can have a look at it – ravikt Jul 23 '20 at 12:46
1

I found that running

ln -fs /usr/share/zoneinfo/UTC /etc/localtime

before setting DEBIAN_FRONTEND=noninteractive worked for me. (You'd want to replace the bit after zoneinfo with whatever is applicable for you.)

If you need it to be set dynamically, [this answer] (https://stackoverflow.com/a/63153978/1995015) suggests calling out to a website that can provide that.

quietkatalyst
  • 97
  • 2
  • 8