Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

docker - How to silent install Postgresql in Ubuntu via. Dockerfile?

I have the following docker file, and I am using the command docker build -t demo:v1 . to build the image.

FROM ubuntu:18.04
WORKDIR /app
RUN apt update 
    && apt -y upgrade 
    && apt install -y python3 
    && apt install -y python3-pip 
    && apt install -y poppler-utils 
    && apt install -y libsm6 libxext6 libxrender-dev

RUN apt install -y postgresql

COPY requirements.txt /app/requirements.txt

RUN pip3 install -r requirements.txt

COPY . /app

CMD gunicorn -t 300 --workers 5 --bind  0.0.0.0:8080 wsgi

When I build an image using this, while installing postgresql, it expects input and stops the building process like this

.
.
.
.
Setting up libpopt0:amd64 (1.16-11) ...
Setting up tzdata (2019c-0ubuntu0.18.04) ...
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:

So, how can I setup postgresql inside my image, so that it builds without expecting this input? Also, surprisingly, even after I input my option, nothing happens further, and the process gets stuck.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

add this to your Dockerfile

ARG DEBIAN_FRONTEND=noninteractive

before installing postgresql

and I think you may want to use apt-get instead of apt to avoid this warning:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...