Running Docker Containers on VeloxaHost: Patterns and Best Practices

VeloxaHost instances run on Incus, which natively supports Docker as a workload inside container and VM instances. Here's how to get the most out of Docker on VeloxaHost.

Installing Docker

On a fresh Ubuntu 22.04 instance:

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Deploying with docker compose

Create /srv/myapp/docker-compose.yml:

services:
  web:
    image: myapp:latest
    restart: unless-stopped
    ports: ["80:8000"]
    environment:
      DATABASE_URL: ${DATABASE_URL}
  db:
    image: postgres:16-alpine
    restart: always
    volumes: [db_data:/var/lib/postgresql/data]
volumes:
  db_data:
docker compose up -d

Using VeloxaHost Storage for Persistent Volumes

Mount a VeloxaHost storage volume (not an instance disk) for data you need to persist across instance replacements:

volumes:
  db_data:
    driver: local
    driver_opts:
      type: none
      device: /mnt/gh-storage/db
      o: bind

Networking Between Instances

Use VeloxaHost's private networking to connect containers across instances without exposing ports publicly. Instances on the same network can reach each other by hostname.

💡

Use a VeloxaHost Load Balancer in front of multiple instances running the same Docker service for high availability without any additional configuration.

Monitoring Docker Containers

VeloxaHost's built-in monitoring tracks instance-level CPU and memory. For container-level visibility, add cAdvisor:

docker run -d --restart always \
  -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gcr.io/cadvisor/cadvisor:latest

Then create a VeloxaHost alert for instance CPU > 80% to get notified when any container is misbehaving.