После запуска команды docker-compose up я получаю одно из предупреждений от db_1 выглядит следующим образом:
Код: Выделить всё
.
.
.
db_1 | ****************************************************
db_1 | WARNING: No password has been set for the database.
db_1 | This will allow anyone with access to the
db_1 | Postgres port to access your database. In
db_1 | Docker's default configuration, this is
db_1 | effectively any other container on the same
db_1 | system.
db_1 |
db_1 | Use "-e POSTGRES_PASSWORD=password" to set
db_1 | it in "docker run".
db_1 | ****************************************************
.
.
.
Структура моего проекта:
Код: Выделить всё
├── config/
│ ├── .env
├── src/
│ ├── manage.py
│ └── core
│ | ├── __init__.py
│ | ├── settings.py
│ | ├── urls.py
│ | ├── wsgi.py
├── docker-compose.yml
├── Dockerfile
└── requirements.txt
Код: Выделить всё
FROM python:3.7.0
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
Код: Выделить всё
version: '2'
services:
db:
image: postgres
restart: always
env_file:
- ./config/.env
web:
build: .
stdin_open: true
tty: true
command: python src/manage.py runserver 0.0.0.0:8000
restart: always
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
Код: Выделить всё
PGUSER=admin
PGDATABASE=db
PGPASSWORD=s3cr3t
PGHOST=h0st
PGPORT=5432
Я следую этой логике переменных среды, заданных самим PostgreSQL:
https://www.postgresql.org/docs/10/libpq-envars.html
Подробнее здесь: https://stackoverflow.com/questions/576 ... en-set-for