Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 845
Parthapratim Neog Avatar asked Dec 12 '19 06:12

Parthapratim Neog


People also ask

Can I use PostgreSQL without install?

psql is part of the Postgres "installation" can be used without any further steps. Any JDBC based query tool can also be used without "installing" a driver, as you can put the JDBC driver's . jar file anywhere you want.


Video Answer


1 Answers

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.

like image 102
LinPy Avatar answered Oct 01 '22 04:10

LinPy