Containerization has revolutionized how developers deploy applications. Docker packages your application with all its dependencies, ensuring consistent behavior across development, testing, and production environments. When combined with Vultr's high-performance SSD VPS, you get lightning-fast deployments with excellent reliability.
Key benefits of running Docker on Vultr include:
Before we begin, you'll need:
Connect to your Vultr instance via SSH, then follow these steps to install Docker:
# Update package index
sudo apt update
# Install prerequisites
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
# Add Docker GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Add Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verify installation
sudo docker --version
After installation, add your user to the docker group to run Docker without sudo:
sudo usermod -aG docker $USER
# Log out and back in, or run:
newgrp docker
For production deployments, Docker needs proper configuration for security and performance:
# Create Docker config directory
sudo mkdir -p /etc/docker
# Configure Docker daemon
sudo tee /etc/docker/daemon.json << 'EOF'
{
"storage-driver": "overlay2",
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"live-restore": true,
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 64000,
"Soft": 64000
}
}
}
EOF
# Restart Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
# Enable Docker on boot
sudo systemctl enable docker
Let's deploy a practical application - a simple Node.js API. Create a project directory and necessary files:
# Create project directory
mkdir -p ~/myapp && cd ~/myapp
# Create a simple Node.js app
cat > index.js << 'EOF'
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.json({ message: 'Hello from Docker on Vultr!', timestamp: new Date() });
});
app.listen(port, () => {
console.log(`App listening on port ${port}`);
});
EOF
# Create package.json
cat > package.json << 'EOF'
{
"name": "myapp",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.18.2"
}
}
EOF
# Create Dockerfile
cat > Dockerfile << 'EOF'
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
EOF
For complex applications with multiple services (database, cache, frontend), use Docker Compose:
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- DB_HOST=postgres
depends_on:
- postgres
- redis
restart: unless-stopped
postgres:
image: postgres:15-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=your_secure_password
- POSTGRES_DB=myapp
restart: unless-stopped
redis:
image: redis:7-alpine
restart: unless-stopped
volumes:
postgres_data:
EOF
# Start all services
docker compose up -d
# Check status
docker compose ps
When running Docker in production on Vultr, follow these security guidelines:
USER directive in Dockerfile--cap-drop=ALL and add only needed capabilitiesDOCKER_CONTENT_TRUST=1Choose the right Vultr plan based on your container workloads:
| Use Case | Plan | vCPUs | RAM | SSD | Price |
|---|---|---|---|---|---|
| Development/Test | Regular Cloud Compute | 1 | 1 GB | 25 GB | $5/mo |
| Small Production App | Regular Cloud Compute | 2 | 4 GB | 80 GB | $25/mo |
| Medium Workload | High Performance | 4 | 8 GB | 160 GB | $40/mo |
| Enterprise/Large Scale | High Performance | 8 | 16 GB | 320 GB | $80/mo |
Now that you have Docker running on Vultr, explore these advanced topics:
Related: Cloudbet Guide for sports betting insights and tutorials.
🎯 Recommended Betting Platforms