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
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"
Django (service name: web)Django was changed to web. Build from the Dockerfile in it. instruction tells dockerto expose a specific network port (in this case,8000`) when the container is run.LINKS instruction to link the container with other services. (This time, postgres)command instruction overwrites the command executed when the container is executed. (This time, gunicorn app.wsgi -b 0.0.0.0:8000) * gunicorn will be described separately.volumes instruction declares that the specified directory is a volume. It is specified in relation to (host: container).Django application directory in ./web:/usr/src/app../web/static/:/usr/src/appstatic.Nginx (service name: nginx)command and pull it. This time, pull thenginx` image.PORTS instruction tells you to forward port 80 on the host and port 80 on the container.VOLUMES instruction to copy the nginx.conf file under the nginx directory of the host to the / etc / nginx directory of the container.VOLUMES instruction declares that the / www / static directory is explicitly used as a volume. (Directory containing static files)VOLUMES_FROM instruction tells you to mount Web (the directory for Django). (To import static files)PostgreSQL (service name: postgres)postgres image.PORTS instruction tells you to forward port 5432 on the host and port 5432 on the container.Next time, I'll cover the initial setup of the Django framework.
Recommended Posts