Proxmox: Quickly Building Ubuntu Containers

Proxmox: Quickly Building Ubuntu Containers

I use a large number of containers within Proxmox. These are typically based on the latest version of Ubuntu. Nothing major here, but this is the quick copy-and-paste script that I use after spinning up the container.

// Log into the CT as root

# Set the language
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8

# Add a non-root user
adduser your_username
usermod -aG sudo your_username

# Set the update script
echo '#!/bin/bash' >> /etc/cron.daily/local
echo 'apt-get update > /dev/null 2>&1' >> /etc/cron.daily/local
echo 'apt-get -y dist-upgrade > /dev/null 2>&1' >> /etc/cron.daily/local
echo 'apt-get -y autoremove > /dev/null 2>&1' >> /etc/cron.daily/local
echo 'apt-get clean > /dev/null 2>&1' >> /etc/cron.daily/local
chmod 755 /etc/cron.daily/local

# Set the TZ
# In my case: ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
ln -sf /usr/share/zoneinfo/Your/Timezone /etc/localtime

# Perform an update
apt-get update && apt-get -y dist-upgrade && apt-get autoremove -y && apt-get clean

# Reboot to finish
reboot
Show Comments