Deploy Django App With Docker and Gunicorn in 3 Easy Steps

Step 1: Create a Dockerfile

FROM python:3.8
WORKDIR /code
RUN pip install Django gunicornCOPY . .ENTRYPOINT [“gunicorn”, “awesome_project.wsgi:application”, “--bind”, “0.0.0.0:8000”]

Step 2: Build docker image

docker build -f Dockerfile -t awesome-app:latest .

Step 3: Run docker image

docker run --rm -p 8000:8000 awesome-app

Test

curl http://127.0.0.1:8000/hello/Hello! This is awesome!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store