Home > Net >  Unable to locate package postgresql-client-11 in python v3.9.6 or above base image
Unable to locate package postgresql-client-11 in python v3.9.6 or above base image

Time:07-02

FROM python:3.9.5

RUN apt-get update && apt-get install -y  postgresql-client-11

for Dockerfile above, docker build commands works smoothly.

But

FROM python:3.9.6

RUN apt-get update && apt-get install -y  postgresql-client-11

docker build throws the following error.

#5 2.088 Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
#5 3.086 Fetched 8545 kB in 3s (3341 kB/s)
#5 3.086 Reading package lists...
#5 3.605 Reading package lists...
#5 4.113 Building dependency tree...
#5 4.251 Reading state information...
#5 4.356 E: Unable to locate package postgresql-client-11

Unable to locate package postgresql-client-11 in python v3.9.6 or above base image

CodePudding user response:

This works for me

FROM python:3.9.6-buster

RUN apt-get update && apt-get install -y  postgresql-client-11

Looks like the bullseye version (by default for python:3.9.6 image) does not have postgresql-client-11 library, but the buster version have it.

CodePudding user response:

Try this for cleaner install:

FROM python:3.10.4-alpine3.16

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1


RUN pip install --upgrade pip

# copy project install deps
# install deps for psycopg build and run pip
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps \
    gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev libffi-dev


WORKDIR /api
COPY requirements.txt requirements.txt
RUN pip install -r ./requirements.txt
RUN apk del .tmp-build-deps
  • Related