[PYTHON] Make Django's environment Docker (Docker + Django + Gunicorn + nginx) Part 2

Last time has described up to nginx.conf. This time, I would like to write mainly about docker-compose.yml, including the details.

It is open to the public below. Please refer to it together with the article. Dockerize Django Environment


Initial settings of docker-compose.yml

docker-compose.yml


version: '2'
services:
  web:
   restart: always
   build: ./web
   expose:
     - "8000"
   links:
     - postgres:postgres
   command: gunicorn app.wsgi -b 0.0.0.0:8000
   volumes:
     - ./web:/usr/src/app
     - ./web/static/:/usr/src/app/static
  nginx:
    restart: always
    image: nginx
    ports:
      - "80:80"
    volumes:
      - "./nginx/:/etc/nginx/"
      - /www/static
    volumes_from:
      - web
    links:
      - web:web
  postgres:
   image: postgres
   ports:
     - "5432:5432"
  1. Definition of container for Django (service name: web)
  1. Definition of container for Nginx (service name: nginx)
  1. Definition of container for PostgreSQL (service name: postgres)

Fitting point

  1. Static files cannot be delivered unless the static file directory is explicitly declared as a volume.

Next time, I'll cover the initial setup of the Django framework.

Recommended Posts

Make Django's environment Docker (Docker + Django + Gunicorn + nginx) Part 2
Make Django's environment Docker (Docker + Django + Gunicorn + nginx) Part 3
Build Django + NGINX + PostgreSQL development environment with Docker
Create Nginx + uWSGI + Python (Django) environment with docker
Docker + Django + React environment construction
[With image diagram] Nginx + gunicorn + Flask converted to Docker [Part 2]
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
[With image diagram] Nginx + gunicorn + Flask converted to Docker [Part 1]
Rebuild Django's development environment with Docker! !! !! !!
Create Python + uWSGI + Nginx environment with Docker
Django + Docker
Nginx setting summary (Flask + Docker + Gunicorn edition)
Build NGINX + NGINX Unit + MySQL environment with Docker
Build Python + django + nginx + MySQL environment using docekr
Make pyautogui [super-appropriate] compatible with multi-display environment Part2
[Python] Build a Django development environment with Docker
Make pyautogui [super-appropriate] compatible with multi-display environment Part1
Using Flask with Nginx + gunicorn configuration [Local environment]
Django environment construction
Django begins part 1
Django begins part 4
django environment construction
Django + Docker command
Launch a Python web application with Nginx + Gunicorn with Docker
How to build a Django (python) environment on docker
Web application made with Python3.4 + Django (Part.1 Environment construction)
Build a development environment with Poetry Django Docker Pycharm
Create a django environment with docker-compose (MariaDB + Nginx + uWSGI)