
Hello peps, If you are searching for the “How to host your Django app in VPS” without hassle. Then this write up is for you.
At first, let me introduce you with Docker.
Docker is a revolutionary containerization technology that simplifies the deployment of applications, making them more portable, scalable, and easy to manage.
Enough intro, now let’s jump to the topic. : D
Prerequisite:
- Any Linux VPS with Ubuntu/Debian OS
- Docker installed in VPS
Installing Docker in VPS
- Download / Clone the installer file from here into your VPS
- chmod +x installer.sh
- then run ./installer.sh
After finishing installation, run
$ sudo docker run hello-world
Then result will be like below attachment (Fig: 1). If not then try to reinstall or find where is the issue.

Installation part is done. : D
Now, clone your Django app in your VPS and must have requirements.txt
Creating Dockerfile:
As we are hosting our app using Docker. So, We need to write a Dockerfile.
What is Dockerfile?
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
Let’s create a Dockerfile, add the below commands and save
$ cd myproject
$ nano Dockerfile
# Use an official Python runtime as the base image
FROM python:3.9
# Set the working directory in the container
WORKDIR /myproject
# Copy the requirements file into the container
COPY requirements.txt /myproject/
# Install the required dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the Django app code to the container
COPY . /myproject/
# Expose the port on which the Django app will run
EXPOSE 8000
# Define the command to run the Django app
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Running the host
We almost done the installation and setup part. Now, let’s run our application. Run below commands to live your application
$ sudo docker build -t my-app:latest .
$ sudo docker run -d -p 80:8000 my-app:latest
Now your app is successfully live. To check your app’s status run this command
$ sudo docker ps
You will see your running application list like this (Fig: 2).

Now,
- Go to http://<your_vps_ip>:80 , 💥 Boom! Your first app is live successfully! : D
Thanks for your patience to read this write up. 🙌
Pardon me for my broken English 🙏
Kudos to Rudra Sarkar for helping me to understand Docker ❤