Useful Ubuntu 22.04 VM Commands

Setting up Cloud-Init


  1. Set user to root
  2. Give root user a password
  3. Set to no (not enough storage, yet)
  4. Set network settings
  5. Regenerate Image

Now you can start the VM

Select xterm.js under the Console pull down for copy/paste functions


Resize the Bootdisk (/dev/sda)

Hardware > Hard Disk (scsi0) > Disk Action > Resize


Expand VM Disk using parted (/dev/sda1)

parted /dev/sda
resizepart 1
Fix/Ignore? Fix
Partition number? 1
Yes/No? Yes
End? [2146MB]? -0
(parted) quit

Get SSH Going

sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' -e 's/^PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
rm /etc/ssh/sshd_config.d/60-cloudimg-settings.conf
systemctl restart sshd

Add Guest Agent

apt-get update && apt-get -y upgrade
apt-get install -y qemu-guest-agent


Install Docker

sh <(curl -sSL

Install Docker Compose

LATEST=$(curl -sL | grep '"tag_name":' | cut -d'"' -f4)
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -sSL$LATEST/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
docker compose version

Add Dockge

  • Install Docker Compose first
mkdir -p /opt/{dockge,stacks}
wget -q -O /opt/dockge/compose.yaml
cd /opt/dockge
docker compose up -d

Dockge GUI, https:// IP:5001

Add Portainer

  • Docker run
docker volume create portainer_data
docker run -d \
  -p 8000:8000 \
  -p 9443:9443 \
  --name=portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \

Portainer GUI, https:// IP:9443