How to Install Docker and Run Your First Container on a VPS
Docker makes it easy to run and manage isolated applications on any system. Whether you're hosting a game server, control panel, or backend service, Docker can simplify deployment dramatically. In this guide, we’ll walk you through installing Docker on a Ubuntu VPS and running your first container.
Why Use Docker on a VPS?
- Isolation: Containers run separately from the host system.
- Portability: Move containers between machines easily.
- Reproducibility: Run the same environment every time.
- Speed: Lightweight compared to full VMs.
Perfect for game server tools, control panels, or microservices.
Step 1: Update Your VPS
Make sure your VPS is up to date:
sudo apt update && sudo apt upgrade -yStep 2: Install Docker
Run the following commands:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.shTo verify Docker installed correctly:
docker --versionYou should see something like:
Docker version 24.0.5, build ced0996Step 3: Add Your User to the Docker Group
This allows you to run Docker without sudo every time.
sudo usermod -aG docker $USERLog out and back in for the change to apply, or run:
newgrp dockerStep 4: Run Your First Container
Let’s try something simple:
docker run hello-worldDocker will download a test image and output a success message if everything works.
Step 5: Run a Web Server Container (Optional)
As a real example, let’s run NGINX on port 80:
docker run -d -p 80:80 --name webserver nginxYou can now visit your VPS IP in a browser and see the default NGINX page.
Step 6: View Running Containers
docker psTo stop your container:
docker stop webserverTo remove it:
docker rm webserverSummary
You’ve now got Docker installed and running on your VPS, along with your first container. This sets the stage for more complex services, including game panels, monitoring tools, databases, and beyond.