-
Notifications
You must be signed in to change notification settings - Fork 0
4.1 Containerization
To make a sudo user using Ubuntu 22.04, start by making a new user with sudo useradd [name]
- Set a password with
sudo passwd [name] - Make them a sudo user with
sudo usermod -aG sudo [name]
This process is the same as CentOS but instead of wheel in the usermod command we use sudo
To start with, we have to finish the initial setup of the new Ubuntu box. I started with the IP addresses by editing the file at /etc/netplan/00-installer-config.yaml and using the following headers and fields:
I then ran netplan apply and pinged both inside and outside the network to check connectivity.
I updated the "preserve_hostname" value to true in /etc/cloud/cloud.cfg so it would stick with the same hostname upon restart
Then I used hostnamectl set-hostname docker01-elizabeth to set the hostname, and I updated /etc/hosts with the new hostname and ip address (replacing the default "ubuntu")
I then restarted the server to make sure that the hostname was going to stick
At this point everything was happy. I was able to ping by hostname both inside and outside of docker01.
Allow things through the firewall using UFW like so:
sudo ufw allow [port]
I used the tutorial at this website: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
In short, here is what I did:
sudo apt update - get the updated list of packages
sudo apt install apt-transport-https ca-certificates curl software-properties-common - Install a few pre-requisites
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - Install the GPG key for the official docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" - add the docker repository as a place the box can look for things
Double check that you are about to install from the Docker repo instead of the default Ubuntu one: apt-cache policy docker-ce
INSTALL DOCKER!!!
sudo apt install docker-ce
You can check the status of docker with: sudo systemctl status docker
Start by confirming the latest version of docker compose on this website: https://github.com/docker/compose/releases
For me this was 2.24.5, so that's what I used in the command below:
sudo curl -L "https://github.com/docker/compose/releases/download/2.24.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose - Set the proper permissions to allow the docker-compose command to be executable
docker compose version - check the version of docker compose
docker run --rm archlinux:latest /bin/echo "Hello SYS265 from Arch Linux"
- Run the echo "Hello SYS265 from Arch Linux" command on the arcb linux container
docker images - show the current images on the vm
Use the following commands to show the kernel running on the arch linux and the host, notice that they are the same:

Pull a python image from the docker repo: docker run -d -P training/webapp python app.py
- The “-d” tag makes it so the image is running in the background and not the foreground, which is the default. The “-P” tag exposes the open ports of the image and assigns them to random open ports on the host.
Next it was time to use docker-compose to set up a wordpress image to run on docker01. I made a new directory for the pertinent files and used the config from this file

Bring the container up with docker compose up -d and shut it down with docker compose down
View active containers with docker ps