Docker - VBychkov-boop/Spring-SYS265-Final-Project GitHub Wiki

Grav CMS on Docker — Ubuntu Server Setup Guide

A step-by-step guide to getting Grav CMS running inside Docker on a fresh Ubuntu Server VM. Written for people accessing their VM either directly via console or through PuTTY over SSH.


Requirements

  • Ubuntu Server 22.04 VM (Hyper-V, VMware, VirtualBox, or bare metal)
  • A user account with sudo access
  • Internet access from the VM
  • A browser on another machine on the same network (to access Grav once it's running)

Phase 1 — Boot & Login

Power on your VM. Once the boot sequence finishes, you'll land on a login prompt that looks like this:

Ubuntu 22.04 LTS Docker01-B1 tty1
Docker01-B1 login: _

Type your username and hit Enter, then your password and hit Enter again. Nothing shows on screen when you type the password — that's normal.

Once logged in, your prompt should look something like:

youruser@Docker01-B1:~$

If you're connecting via PuTTY instead:

  • Open PuTTY, enter your VM's IP, port 22, connection type SSH, click Open
  • Accept the host key alert on first connection
  • Log in with your username and password
  • To paste commands into PuTTY — right-click (do not use Ctrl+V)

Phase 2 — Update the System

Before touching anything else, pull in the latest package lists and apply any pending updates:

sudo apt update && sudo apt upgrade -y

This can take a few minutes depending on how out of date the system is. If a dialog pops up asking about restarting services, just hit Enter to accept the defaults and move on.


Phase 3 — Install Docker

1. Install dependencies

sudo apt install -y ca-certificates curl gnupg lsb-release

2. Add Docker's GPG key

sudo install -m 0755 -d /etc/apt/keyrings
 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
 
sudo chmod a+r /etc/apt/keyrings/docker.gpg

3. Add the Docker apt repository

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4. Install Docker Engine and Compose

sudo apt update
 
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

5. Confirm Docker is running

sudo systemctl status docker

You want to see active (running) highlighted in green. Press Q to get back to the prompt.

6. Run Docker without sudo

Add your user to the Docker group so you don't have to type sudo in front of every Docker command:

sudo usermod -aG docker $USER

Apply the change to your current session without logging out:

newgrp docker

Test that it worked:

docker run hello-world

If you see Hello from Docker! in the output, you're good to go.


Phase 4 — Set Up the Grav Project

1. Create the project folder

mkdir ~/grav-docker
cd ~/grav-docker

2. Create the Docker Compose file

nano docker-compose.yml

Paste in the following config. If you're in PuTTY, right-click to paste:

services:
 
  grav:
    image: lscr.io/linuxserver/grav:latest
    container_name: grav-site
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - grav-config:/config
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
 
volumes:
  grav-config:

Change TZ=Europe/London to match your timezone — e.g. America/New_York, Australia/Sydney, Europe/Amsterdam.

Save and close nano:

  • Ctrl + O then Enter to save
  • Ctrl + X to exit

Phase 5 — Start Grav

docker compose up -d

Docker will pull the image from LinuxServer.io — first run takes a minute or two. When it's done you'll see:

✔ Container grav-site  Started

Check the container is actually up:

docker compose ps

grav-site should show status Up. If it shows Exited, check the logs with docker compose logs grav to see what went wrong.


Phase 6 — Install the Admin Panel

Grav doesn't include the admin UI out of the box. Drop into the container and install it:

docker exec -it grav-site bash

Your prompt will change to something like root@5eaf65085f80:/# — you're now inside the container.

bin/gpm install admin

Type Y when it asks for confirmation. Once it finishes:

exit

You're back on the host now.


Phase 7 — Find Your IP and Open Grav

Run this on the host VM (not inside the container):

ip a

Find the interface that isn't lo (loopback) — usually named eth0 or ens33. Look for the inet line under it:

2: eth0: ...
    inet 192.168.1.50/24 ...

That 192.168.1.50 (yours will differ) is what you put in the browser.

Open a browser on any machine on the same network and go to:

http://192.168.x.x:8080

You should land on the Grav default page. For the admin panel:

http://192.168.x.x:8080/admin

The first time you load the admin panel it'll ask you to create an admin account — set a username and a strong password and you're in.


Useful Commands

What you want to do Command
Start the stack docker compose up -d
Stop the stack docker compose down
View live logs docker compose logs -f grav
Shell into the container docker exec -it grav-site bash
Install a plugin bin/gpm install <plugin-name>
Install a theme bin/gpm install <theme-name>
Update Grav core bin/gpm selfupgrade
Update all plugins bin/gpm update
Pull latest image docker compose pull
Restart the container docker compose restart

Troubleshooting

Can't reach the site from another machine Check if the firewall is blocking port 8080:

sudo ufw status

If it's active, allow the port:

sudo ufw allow 8080

Container keeps exiting Check the logs to see the actual error:

docker compose logs grav

Forgot to exit the container before running ip a If your IP starts with 172.x.x.x you're still inside the container. Run exit first, then run ip a again on the host.

Grav admin page not loading after installing the plugin Give it 10–15 seconds and refresh. The container may need a moment to register the new plugin. If it still doesn't load, restart the container:

docker compose restart
⚠️ **GitHub.com Fallback** ⚠️