4

I found a Django project and failed to get it running in Docker container in the following way:

  1. git clone https://github.com/hotdogee/django-blast.git

I have the following Dockerfile:

FROM python:2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

For docker-compose.yml I use:

version: "3"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

Next, I ran into this error:

$ docker-compose build
...
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info
         cwd: /tmp/pip-install-Gq_JSR/psycopg2/
    Complete output (7 lines):
    running egg_info
    creating /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info
    writing /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file '/tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: could not determine PostgreSQL version from '11.7'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.0.2; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

What did I miss?

Thank you in advance

1 Answer 1

8

Error: could not determine PostgreSQL version from '11.7'

Known bug for psycopg2<=2.6.2. Try upgrading by editing its requirements.txt and changing psycopg2==2.6.0 to psycopg2==2.7.

5
  • Thank you. Unfortunately, after docker-compose up I got Firefox can’t establish a connection to the server at localhost:8000. What did I miss?
    – user977828
    May 15, 2021 at 13:12
  • did you deploy the compose file and run Firefox at the same machine?
    – mforsetti
    May 15, 2021 at 13:17
  • Yes, I did. After, I posted I forgotten to change kombo to 3.0.30 in requirements.txt (source). Unfortunately, I got a new error ImportError: /usr/local/lib/python2.7/site-packages/psycopg2/.libs/./libresolv-2-c4c53def.5.so: symbol __res_maybe_init version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference. What did I miss?
    – user977828
    May 15, 2021 at 13:36
  • 1
    Try using latest psycopg2, psycopg2==2.8.6 in your requirements.txt, and try running it again.
    – mforsetti
    May 15, 2021 at 15:24
  • Thank you, this fix it, but I got a new error: web_1 | django.db.utils.OperationalError: could not connect to server: Connection refused web_1 | Is the server running on host "127.0.0.1" and accepting web_1 | TCP/IP connections on port 5432? . What did I miss?
    – user977828
    May 16, 2021 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .