Docker Community Forums

Share and learn in the Docker community.

ERROR: unsatisfiable constraints: postgresql-client (missing): required by: world[postgresql-client]

Please, I am a beginner, can someone help me! Anytime i run docker-compose build, i got the following errors:

WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
  postgresql-client (missing):
    required by: world[postgresql-client]
ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add --update --no-cache postgresql-client' returned a non-zero code: 1

Below is my Dockerfile:

FROM python:3.7-alpine
MAINTAINER Tboost Technology
#set environment variable
ENV PYTHONUNBUFFERED 1

#install dependencies
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
    gcc libc-dev python3-dev linux-headers postgresql-dev
RUN pip3 install -r /requirements.txt
RUN apk del .tmp-build-deps

#mkdir to store your apps source code
RUN mkdir /app
WORKDIR /app
COPY ./app /app

#create user to run apps in the docker
RUN adduser -D user
#switch to the user
USER user

Here is my docker-compose.yml file

version: "3"

services: 
    app:
        build: 
            context: .
        ports: 
            - "8000:8000"
        extra_hosts: 
            - "host.docker.internal:172.17.0.1"
        volumes: 
            - ./app:/app
        command: >
            sh -c "python manage.py runserver 0.0.0.0:8000"
        environment: 
            - DB_HOST=db
            - DB_NAME=app
            - DB_USER=postgres
            - DB_PASS=supersecretpassword
        depends_on: 
            - db
    
    db:
        image: postgres:11-alpine
        restart: always
        environment: 
            - POSTGRES_DB=app
            - POSTGRES_USER=postgres
            - POSTGRES_PASSWORD=supersecretpassword

Below is my requirements.txt file:

Django>=3.0.7,<3.0.8
djangorestframework>=3.11.0,<3.12.0
psycopg2>=2.7.5,<2.8.0

flake8>=3.6.0,<3.7.0

in your initial RUN directive, I believe you need to update the apk package manager.
apk update && apk add --update --no-cache postresql-client
That properly installed the client on a local container…
I saw those initial warnings doing a search for postgresql*
then i did apk update, then the search and it all worked properly.

This post was flagged by the community and is temporarily hidden.

This post was flagged by the community and is temporarily hidden.