How to Set Up a New Django Project in a Docker Container

Step 1: Install Docker

Step 2: Get initial docker files

These files will be used to build the container, and install the dependencies needed to create the django project. They can be found here.

Step 3: Build the Docker Container

Type the command:

docker build .

Step 4: Spin up the Docker container.

Type the command:

docker-compose run web /bin/bash

You will now have an active terminal inside the running docker container.

Step 5: Create a new Django project inside the container

The docker-compose file contains a reference to a specific project name (recipe_proj). Modify this to reflect a new project name of your choice.
Type the commands:

django-admin startproject PROJECT_NAME

This command will create a new django project folder.

Step 6: Create the application

Move into the project folder that was created in the above step. Then enter the command:

python manage.py startapp APP_NAME

This will create the starter application files for your project.