
You should see a log statement similar to this one in the output of devspace dev: # In addition to deploying our Django application to Kubernetes, the devspace dev command also starts a powerful development UI which runs on localhost and is available as long as the devspace dev command is running. You can customize what happens within the DevSpace config file devspace.yaml which devspace init created for your project.Īfter devspace dev has successfully deployed, you should see a log output of Django inside the command-line and the browser will open up with our Django site showing a beautiful welcome page: Django Welcome Page - If you see this one, you're doing everything right so far!


Change the last line in this Dockerfile from: CMD If you are not sure about the Docker registry or other questions, just choose the default option that DevSpace recommends for you.Īfter we containerized the project, DevSpace added a Dockerfile to the project.
#Django docker tutorial install
It is open-source and you can install it from GitHub.Īfter DevSpace is installed on your computer, you can containerize your Django project using this command: devspace initĭevSpace will ask a couple of questions. DevSpace is a cloud-native dev tool for Kubernetes. So, let's automate containerizing our Django project using DevSpace.

Of course, we could manually create a Dockerfile, Kubernetes manifests or even a Helm chart but that is a lot of work and quite error-prone. Now, let's containerize our Django project. Now, we are creating a new Django project using Docker: mkdir $PROJECT_DIRĭocker run -rm -v / $PROJECT_DIR:/app -w //app python bash -c "pip install django & django-admin startproject $PROJECT_NAME & pip freeze > $PROJECT_NAME/requirements.txt" cd $PROJECT_DIR/ $PROJECT_NAME We should also define a variable for the project name: PROJECT_NAME=mysite # warning: Django only allows characters a-z, no -, space or anything else If you are using Docker Desktop on Windows, make sure you have the drive that your project should be on marked as Shared Drive in the Docker settings.
#Django docker tutorial windows
because you are using Windows Home Edition), your $PROJECT_DIR needs to be inside your user's home directory, e.g.

If you are using the legacy Docker Toolbox (e.g. PROJECT_DIR=/home//django # for unix-based systems (mac, linux) If you already have a Django project, you can skip this step but make sure you have a requirements.txt within your project's root directory (run pip freeze > requirements.txt to create it).īefore creating a new Django project, let's define a variable with the directory that we want our Django project to be located in: PROJECT_DIR=/c/Users//django # for git-bash on windows Everything works with any Kubernetes cluster, no matter if it is a local single-node cluster created with minikube or Docker Desktop, if it's a fully managed cluster in GKE, AKS or EKS, or if it is a vCluster created with loft 1. This tutorial is independent of any cloud platform. This tutorial is meant to be a guide for Django developers who want to explore Kubernetes and boost their productivity when building and deploying Django projects using Kubernetes. Scalable Django Deployment using Kubernetes and DevSpace.
