Containerization has become the standard for modern application deployment, and Docker remains the leading platform. In this comprehensive guide, we'll walk you through setting up Docker on your Vultr VPS, from initial server setup to production-ready deployment.
Vultr provides an ideal environment for Docker deployment for several reasons:
First, create a new VPS instance on Vultr with Ubuntu 22.04 LTS or 24.04 LTS:
# Update system packages
sudo apt update && sudo apt upgrade -y
# Create a non-root user (recommended for production)
sudo adduser dockeruser
sudo usermod -aG sudo dockeruser
Docker provides an official installation script that works on Ubuntu:
# Install Docker using the convenience script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add your user to the docker group
sudo usermod -aG docker $USER
# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Verify the installation:
docker --version
docker run hello-world
Docker Compose is essential for managing multi-container applications:
# Install Docker Compose v2
sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# Verify installation
docker-compose --version
Configure UFW to allow necessary Docker ports:
# Install UFW if not present
sudo apt install ufw -y
# Allow SSH (important!)
sudo ufw allow 22/tcp
# Allow HTTP and HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Enable firewall
sudo ufw enable
sudo ufw status
Let's deploy a simple Nginx web server as a practical example:
# Pull and run Nginx
docker run -d \
--name my-nginx \
-p 80:80 \
-v /var/www/html:/usr/share/nginx/html \
nginx:alpine
# Check container status
docker ps
# View logs
docker logs my-nginx
For real-world applications, use Docker Compose to define your stack:
# Create project directory
mkdir -p ~/myapp && cd ~/myapp
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
web:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./html:/usr/share/nginx/html
restart: unless-stopped
app:
image: node:18-alpine
working_dir: /app
volumes:
- .:/app
command: node server.js
restart: unless-stopped
db:
image: postgres:15
environment:
POSTGRES_PASSWORD: securepassword
volumes:
- db-data:/var/lib/postgresql/data
restart: unless-stopped
volumes:
db-data:
EOF
# Start all services
docker-compose up -d
# View status
docker-compose ps
Essential commands for managing your Docker environment:
| Command | Description |
|---|---|
docker ps |
List running containers |
docker ps -a |
List all containers |
docker logs -f [container] |
Follow container logs |
docker exec -it [container] sh |
Access container shell |
docker-compose logs -f |
View all service logs |
docker system prune |
Clean up unused resources |
For production monitoring, consider these tools:
# Quick monitoring with docker stats
docker stats
# Install Portainer for easy management
docker run -d \
--name portainer \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer-data:/data \
portainer/portainer-ce:latest
Get started with Vultr's high-performance VPS and deploy your Docker containers today. New users get $100 credit!
Setting up Docker on Vultr is straightforward and provides a powerful foundation for deploying containerized applications. Whether you're running a simple web server or a complex microservices architecture, Vultr's global infrastructure combined with Docker's flexibility gives you everything needed for modern application deployment.
For next steps, explore our guide on Vultr Kubernetes deployment if you need to scale beyond single-server Docker setups.
Tags: Vultr Docker, Docker on VPS, Container deployment, Vultr tutorial, Docker Compose