Docker allows you to run applications in isolated containers on your VPS. It’s lightweight, scalable, and perfect for deploying apps without breaking your system.
Step 1: Update Your VPS
Before installing Docker, make sure your VPS is up to date:
Install required dependencies:
Step 2: Install Docker
-
Add Docker’s official repository:
-
Install Docker:
-
Start and enable Docker:
-
Verify installation:
Step 3: Manage Docker as a Non-Root User
Add your user to the Docker group so you don’t need sudo for every command:
Log out and back in for changes to take effect.
Test with:
You should see a confirmation that Docker is working.
Step 4: Run Your First Container
Let’s run a simple Nginx container:
-
-druns in detached mode -
-p 80:80maps VPS port 80 to container port 80 -
--name mynginxnames the container
Check running containers:
Open your VPS IP in a browser — you should see the Nginx welcome page.
Step 5: Managing Containers
-
Stop a container:
-
Start a container:
-
Remove a container:
-
Remove all stopped containers and unused images to save space:
✅ Tips & Best Practices
-
Use Docker Compose for multi-container apps.
-
Regularly clean unused images and volumes to avoid filling your VPS storage.
-
Consider mounting persistent storage for data-heavy containers.
-
Always monitor container CPU and memory usage:
With Docker on your VPS, you can run isolated apps, quickly deploy websites, APIs, databases, or even full development environments without breaking your VPS.