Deploy Django Application on Docker
1) Create “Dockerfile” in your project directory and write below code.
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
2) Create “docker-compose.yml” in your project directory and write below code.
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile
command: python manage.py runserver 0.0.0.0:8000
ports:
- 8000:8000
volumes:
- .:/app
3) Run command
docker-compose build
docker-compose up