Have a problem with docker-. I writing Django project with Postgres as a database and want to dockerize it. So the problem: when I build&up containers there are an exceptions:
...
polls | Is the server running on host "postgres" (172.19.0.2) and accepting
polls | TCP/IP connections on port 5432?
But if I do it the second time - all is OK and a server is started.
Dockerfile:
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ADD . /code/
docker-compose.yml:
version: '3'
services:
postgres:
image: postgres:latest
container_name: polls_db
env_file:
- ./src/main/.env
volumes:
- ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
polls:
build: .
container_name: polls
volumes:
- .:/code
env_file:
- ./src/main/.env
ports:
- "8000:8000"
depends_on:
- postgres
command: bash -c "python src/manage.py migrate && python src/manage.py runserver 0.0.0.0:8000"