O
O
Oleg Vedernikov2017-10-19 18:33:01
Docker
Oleg Vedernikov, 2017-10-19 18:33:01

Where is the error in docker-compose file?

Good day!
I want to build a django application with postgresql.
dockerfile example

FROM python:3.6
ENV PYTHONUNBUFFERED 1

COPY ./requirements /requirements/
RUN pip install -r /requirements/local.txt

RUN apt-get update && apt-get upgrade

RUN apt-get install -y \
    postgresql-server-dev-all \
    postgresql-client

WORKDIR /app

EXPOSE 8080

docker-compose example
version: "2"
services:
  db:
    image: postgres
    expose:
      - "5432"
  web:
    restart: always
    image: test-project-django
    env_file: ./config/.env
    command: ./manage.py runserver 0.0.0.0:8080
    ports:
      - "8080:8080"
    volumes:
      - .:/app
    links:
      - db

Contents of the .env file
DJANGO_DEBUG=True
DJANGO_SECRET_KEY="secret"
DJANGO_DATABASE_URL=postgres:///docker_django

as a result, when I try to docker-compose up I get the following error
django.db.utils.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tell me, please, how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2017-10-19
@kila

Likbez:
Regarding your problem: you have django configured to connect locally to a database that is not running (and it is not clear why it is in the image at all), while it should be configured to connect to another container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question