Getting podman right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including alternative and linux considerations.
Prerequisites
- Basic familiarity with the Linux command line
- A registered domain name (for public-facing services)
- Docker Engine 24.0+ installed
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Docker Compose v2 installed
Creating the Docker Compose File
Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.
# docker-compose.yml
version: '3.8'
services:
app:
image: podman:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- app_data:/data
environment:
- NODE_ENV=production
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
app_data:
The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.
Building the Container Image
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# Multi-stage Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Summary
You've successfully configured podman on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.