Я пытаюсь запустить проект Django внутри контейнера Docker, используя nginx и gunicorn. Кажется, что сервер wsgi работает успешно, но когда я перехожу на localhost (127.0.0.1:8000), страница не загружается.
Вот моя конфигурация docker -compose.yml:
version: '3'
services:
app:
build:
context: .
ports:
- "8000:8000"
env_file:
- django.env
volumes:
- ./app:/app
command: >
sh -c "python3 manage.py migrate &&
python3 manage.py wait_for_db &&
gunicorn -w 4 "app.wsgi -b 0.0.0.0:8000
environment:
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=supersecretpassword
depends_on:
- db
db:
image: postgres:10-alpine
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=supersecretpassword
ports:
- "5432:5432"
nginx:
build:
context: .
dockerfile: nginx/Dockerfile
ports:
- 80:80
и nginx конфигурация:
server{
listen 80;
server_name localhost;
location / {
proxy_pass http://app:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
наконец, консоль:
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2020-04-13 10:22:22.719 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-04-13 10:22:22.719 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-04-13 10:22:22.833 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-04-13 10:22:23.150 UTC [20] LOG: database system was shut down at 2020-04-13 10:22:16 UTC
db_1 | 2020-04-13 10:22:23.259 UTC [1] LOG: database system is ready to accept connections
app_1 | Operations to perform:
app_1 | Apply all migrations: admin, auth, contenttypes, core, sessions
app_1 | Running migrations:
app_1 | No migrations to apply.
app_1 | Waiting for database...
app_1 | Database available!
app_1 | [2020-04-13 10:22:25 +0000] [1] [INFO] Starting gunicorn 20.0.4
app_1 | [2020-04-13 10:22:25 +0000] [1] [INFO] Listening at: http://127.0.0.1:8000 (1)
app_1 | [2020-04-13 10:22:25 +0000] [1] [INFO] Using worker: sync
app_1 | [2020-04-13 10:22:25 +0000] [9] [INFO] Booting worker with pid: 9
app_1 | [2020-04-13 10:22:25 +0000] [10] [INFO] Booting worker with pid: 10
app_1 | [2020-04-13 10:22:25 +0000] [11] [INFO] Booting worker with pid: 11
app_1 | [2020-04-13 10:22:25 +0000] [12] [INFO] Booting worker with pid: 12
Спасибо за любую помощь!