Docker and Django - How to start fast

This article is a short introduction to Docker and Django, a productive stack that might help beginners and designers to start fast a new project. To make this article more useful, a short-list with open-source Django projects configured to work on Docker is also provided. For newcomers, Django is a leading web framework coded in Python by programming experts and Docker is a popular virtualization platform used to deliver software much faster.


Thanks for reading! Topics covered by this article

  • πŸ‘‰ Section #1 - Short introduction to Django
  • πŸ‘‰ Section #2 - What is Docker
  • πŸ‘‰ Section #3 - Docker CheatSheet
  • πŸ‘‰ Section #4: Pre-configured Docker Projects (all free)

1# - Django Presentation

Django is a modern web framework crafted in Python language that provides modules and libraries for many common features required in modern web development. This amazing library is actively supported and versioned by programming experts and open-source enthusiasts using a batteries-included concept. Here is a short list with features provided by Django out-of-the-box :

  • Session-based authentication, Social Login via Google, Apple .. etc.
  • Out-of-the-box Admin Section with CRUD access for all tables
  • Abstract Database access via a powerful ORM
  • Powerful built-in security patterns (CSRF, XSS)
  • Helpers for almost anything: forms, data validation
  • Administration module
  • A powerful command-line-interface

Django can be installed in many ways and the most recommended way is to use PIP, the official Python package manager. Here is the complete list with commands:

Step #1 - Create a virtual environment

$ # Create the environment
$ virtualenv env 
$
$ # Activate the virtual environment
$ source env/bin/activate
Django - Create Virtual EnvironmentΒ 

Step #2 - Install Django via PIP, the official package manager for Python

$ pip install Django // install latest version
// OR
$ pip install django==2.2.12 // install specific version
Django - Install via PIP

Step #3 - Build a simple Django project

$ mkdir my_django 
$ cd my_django
$
$ django-admin startproject config . 
Django - How to create a project

Step #4 - Start the project

$ python manage.py runserver 
Django - Start the project

Once all the above commands are executed, we should see in the browser the default Django splash screen when accessing http://localhost:8000 .

Django - The Default Screen

2# - What is Docker

According to the official documentation, Docker is virtualization software for developing, shipping, and running applications that provides a clear separation of applications from the infrastructure so we can deliver software much faster and reliable.

Docker - Official Logo.

Basically, Docker provides a way to bundle web apps (and not only) into containers that are executable components built with applications source code and operating system libraries. Once the containers are bundled, Docker provides also a control layer that enables full control over the software: deploy, start, stop, restart and update containers using simple commands. For more information about Docker feel free to access:


3# - Docker CheatSheet

This section is a short introduction to the most used Docker commands.

Inspecting Docker Containers

$ docker --version       # check Docker version
$ docker ps -a           # list all containers
$ docker ps              # list all RUNNING container
Docker Commands - Containers Information

Management Docker Commands

$ docker run     <docker_image>       # create and start the container
$ docker start   <docker_container>   # start container
$ docker stop    <docker_container>   # stop container (gracefully) 
Docker - Management Commands

Image Transfer Commands

$ docker pull  <docker_image>   # pull an image from a registry
$ docker push  <docker_image>   # push/save an image to a registry
Docker - Image Transfer Commands

Miscellaneous Docker Commands

$ docker container kill $(docker ps -q)  # kill all containers
$ docker container rm $(docker ps -a -q) # delete all containers 
Docker - Miscellaneous Commands

4# - Django and Docker Samples

With this minimal Django & Docker introduction in mind we should be able to execute and understand how the samples are built and executed.

✨ Argon Dashboard Django

Simple Django starter crafted on top of a popular Bootstrap 4 design: Argon Dashboard. Β Django codebase is crafted using a simple, modular structure that follows the best practices and provides authentication, database configuration, and deployment scripts for Docker.

$ unzip argon-dashboard-django.zip
$ cd argon-dashboard-django
$
$ docker-compose pull 
$ docker-compose build 
$ docker-compose up
Argon Dashboard Django - Execute in Docker
Django and Docker - Argon Dashboard Sample

✨Soft UI Dashboard Django

Designed for those who like bold elements and beautiful websites, Soft UI Dashboard is ready to help you create stunning websites and web apps. Soft UI Dashboard is built with over 70 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining.

$ unzip soft-ui-dashboard-django.zip
$ cd soft-ui-dashboard-django
$
$ docker-compose pull 
$ docker-compose build 
$ docker-compose up
Soft UI Dashboard Django - Execute in Docker
Django and Docker - Soft UI Dashboard Sample

✨ Black Dashboard Django

Start your development with a modern, dark-themed Bootstrap 4 Admin template for Django. It features a huge number of components built to fit together and look fantastic. If you want to code faster, with a smooth workflow, then you should try this template carefully developed with Django. This template comes in dark mode for your app to keep up with trends. If you are not a dark-mode lover, no worries; this template comes in light mode, too.

$ unzip black-dashboard-django.zip
$ cd black-dashboard-django
$
$ docker-compose pull 
$ docker-compose build 
$ docker-compose up
Black Dashboard Django - Execute in Docker
Django and Docker - Black Dashboard Sample

✨ Django Volt Bootstrap 5

Admin Dashboard generated by AppSeed in Django Framework. Volt Dashboard is a free and open-source Bootstrap 5 Admin Dashboard featuring over 100 components, 11 example pages, and 3 plugins with Vanilla JS. There is more than 100 free Bootstrap 5 components included some of them being buttons, alerts, modals, date pickers, and so on.

$ unzip django-volt-bootstrap-5.zip
$ cd django-volt-bootstrap-5
$
$ docker-compose pull 
$ docker-compose build 
$ docker-compose up
Volt Dashboard Django - Execute in Docker
Django and Docker - Volt Dashboard Sample

✨ Material Dashboard Django

Start your development with a beautiful Material Admin template for Django. Material Dashboard makes use of light, surface, and movement. The general layout resembles sheets of paper following multiple different layers so that the depth and order are obvious. The navigation stays mainly on the left sidebar and the content is on the right inside the main panel.

Django codebase is crafted using a simple, modular structure that follows the best practices and provides authentication, database configuration, and deployment scripts for Docker, a popular virtualization software.

$ unzip material-dashboard-django.zip
$ cd material-dashboard-django
$
$ docker-compose pull 
$ docker-compose build 
$ docker-compose up
Material Dashboard Django - Execute in Docker
Django and Docker - Material Dashboard Sample

Thank you for reading! For more resources, please access: