TL;DR: I am enjoying containerization, and not looking back: the simplicity of deploying, ability to make quick changes, speed of initialization, and the ability to checkout any news containers with ease. I have consolidated most of the services I had hosted on different VMs into my single Docker environment and will eventually (no time soon) move to a container based OS instead of Proxmox.
The other week I posted about containerization, specifically Docker...and more to the point, Docker within an Ubuntu VM on a Proxmox host.
The purpose of this specific configuration was due to my homelab setup, I had been investigating and playing with Proxmox over the last couple of years, having moved from ESXi (which my company used). With the current environment and equipment I had at hand, it's not like I could just take the jump into hosting a container based OS, I had to take baby steps and deploy a VM in which I could run Docker.
Since I have setup Docker, and Portainer for a GUI based management, I have been migrating many of my existing services to the new platform. My experience with YAML via Home Assistant has made things much easier (even if YAML is simple enough, structure can be a curveball for some) and I have moved nearly all services to Docker. Along with existing services, I have also tried out some new services too: WireGuard for a VPN server to tunnel back to my home netwwork, and Gluetun to provide VPN network connections for other containers.
When deploying containers I have been using Portainer's Stack approach, which is equivalent to Docker compose files. I will use my journey with my Grav migration to document the simplicity of working with containes and Stacks/Compose files.
My Grav instance and blog were hosted on an Ubunutu VM on Proxmox, the first thing I needed to do was setup a new Grav container to prepare for migration> To do this I used a Portainer stack and created a specific volume in Docker for the Grav application to host it files.
Step 1: Create a Volume in Portainer
Simply navigate to Portainer | Volumes and click "+ Add Volume" and name your volume e.g., grav-config
The equivalent docker command would be:
docker volume create grav-config
Step 2: Create a stack to deploy Grav
Navigate to Stack, choose "Web Editor" and then paste the appropriate docker compose script into the web editor, my stack follows as an example:
services:
grav:
image: lscr.io/linuxserver/grav:latest
container_name: grav
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
volumes:
- grav-config:/config
ports:
- 80:80
restart: unless-stopped
volumes:
grav-config:
external: true
NOTE: Both volume sections are required, one within the service to define where we will store the Grav data, and the second to indicate that the volume we are referencing is external to the container. Sidenote, I also mounted an NFS location to assist with transferring my Grav blog backup.
After setting up the stack, go ahead and deploy the stack:
Once deployed you can navigate to the host IP, on port 80.
NOTE: Based on my configuration, the container is using the IP of the host, so I just navigate to the IP of my Ubunutu instance, which is running Docker.
And you are good to go, you have setup Grav, now since I was migrating I took a different direction at this point...
Step 3: Migrating Grav instance
Follow these steps to migrate:
zip backup.zip user/
mv user/ userold/
unzip backip.zip
Personally, I had issues with PDO errors relative to my install - these were due to packages I required for my original Grav instance, so I had to install the same packages within my Docker container - if you pages load fine you can skip this section.
Step 4: Fixing PDO Issues from Grav Migration
Log into your container:
docker exec -it grav /bin/bash
Since this is based on Alpine we will be using apk versus apt for package installation. Install the following required packages:
apk add php83-pdo
apk add php83-pdo_sqlite
apk add php83-sqlite3
Restart your Grav container using the following as an example:
exit
docker stop grav
docker start grav
You should be good to go with your freshly installed Grav, now hosting your old posts - indeed this is my first post on my container instance.