Update Docker images and containers for a service.
When to use
- Regular maintenance
- Security updates available
- New features needed
Prerequisites
- [ ] Know the service container CT ID
- [ ] Service is currently running
Updating service configuration
When Docker Compose files or configs change (not just image updates):
1. Push changes from dev laptop
cd ~/dev/homelab-docker
git add -A && git commit -m "description" && git push
2. Pull on the Proxmox host
ssh jan@server "cd /home/jan/homelab-docker && git pull"
Changes are immediately visible inside all LXC containers via bind mount.
3. Restart the affected service
ssh jan@server "sudo pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose up -d'"
Steps (image updates)
1. Check current status
# Check container is running
pct status <CT_ID>
# Check running Docker containers
pct exec <CT_ID> -- docker ps
2. Pull new images
pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose pull'
3. Restart with new images
pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose up -d'
This will:
- Pull new images
- Stop containers with old images
- Start containers with new images
- Preserve data volumes
4. Verify service is working
# Check container status
pct exec <CT_ID> -- docker ps
# Check logs
pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose logs -f'
# Test service
curl http://<service-ip>:<port>
Updating Multiple Services
# Pull latest images for each container
for ct in 120 122 123 124 125 126 127 128 129 130 131; do
echo "Updating CT $ct..."
pct exec $ct -- bash -c 'cd /opt/homelab-docker/<service> && docker compose pull && docker compose up -d'
done
Updating the LXC Template
Periodically update CT 902 (lxc-base):
# Start template
pct start 902
# Update system
pct exec 902 -- pacman -Syu
# Update Docker
pct exec 902 -- pacman -S docker docker-compose
# Stop template
pct stop 902
New services cloned after this will have updated packages. Existing containers are not affected.
Rollback
If an update breaks something:
Option 1: Restart with previous image
# Find previous image
pct exec <CT_ID> -- docker images | grep <service>
# Edit docker-compose.yml to use previous image tag
pct exec <CT_ID> -- nano /opt/homelab-docker/<service>/docker-compose.yml
# Restart
pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose up -d'
Option 2: Restore from backup
See Backup & Restore
Verification
- [ ] Service container is running
- [ ] Service responds to requests
- [ ] No errors in logs
- [ ] Data is intact
Troubleshooting
Container won't start after update:
# Check logs
pct exec <CT_ID> -- bash -c 'cd /opt/homelab-docker/<service> && docker compose logs'
# Rollback to previous image version
Image pull fails:
- Check network connectivity
- Check image name is correct
- Try
docker pull <image>manually