Docker in Promxmox: Migrating my Grav deployment

Debian Proxmox Docker WireGuard Gluetun Grav

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

Screenshot-2024-02-21-12.50.37-PM

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:

Screenshot%202024-02-21%201.50.07%20PM

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:

  1. Instead of creating a real username and password, creae a temporary one when you first log into your new Grav instance - because you will ultimately use your original instance credentials
  2. Go to your old Grav instance and navigate to your user folder e.g., grav-site/www
  3. NOTE: If you look into the user folder within www you should see your pages and media, if so you are good to proceed
  4. Zip up your user folder using zip backup.zip user/
  5. Transfer this zip to your new Grav instance (I personally created another volume for my grav container referencing a NAS location)
  6. Locate your user folder, as you did on your old instance, and rename e.g., mv user/ userold/
  7. Unzip the backup Grav site e.g. unzip backip.zip
  8. Restart Grav container - your old credentials will now work with your new instance (that's why we just ephemeral temp ones)
  9. Once comfortable you can remove the userold folder as it is no longer needed

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:

  1. Exit your Grav container e.g., exit
  2. Stop your Grav container e.g., docker stop grav
  3. Start your Grav container e.g., 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.

Previous Post Next Post