Docker Lab - lizzy9596/sys-265 GitHub Wiki
Docker Lab
The goal of this lab is to configure docker01 and gain experience using docker.
Parts:
- Configuration
- Install Docker
- Install Docker Compose
- "Hello SYS265" Docker image
- Docker Arch Linux Container
- Docker Web Application
- Docker Networking
- Dockerized Wordpress
Configuration:
To start I connected the system to the LAN.
After getting the system booted, I ran the command sudo nano /etc/netplan/00-installer-config.yaml
. I then edited the file as followed (rescoure:
After I updated with the command sudo netplan apply
, I did get a error about inconsistent indentation and had to update the file.
Next I needed to configure the hostname, to do this I ran the command sudo nano /etc/hostname
. I changed it from ubuntu to Docker01-elizabeth. I confirmed by running hostnamectl
.
After configuring hostname I needed to create a name user. To start I did sudo adduser elizabeth-adm
. I then needed to add the user to the sudo user group, I used sudo usermod -aG sudo elizabeth-adm
I then ran the command sudo nano /etc/cloud/cloud.cfg and changed the preserve_hostname setting to true.
I then needed to configure the ssh file. I opened the file with sudo nano /etc/ssh/sshd_config
. I then uncommented and add no to the PermitRootLogin. After I restarted ssh using sudo service ssh restart
I then needed to add docker01 to the domain. I followed this Rescource. To start I changed the hostname using the same command as earlier, but adding elizabeth.local to the end. Next I needed to configure the /resolve.conf file, but the domain was already there!
I then went into mgmt01 to update the DNS records with docker01.
I was unable to ssh, so I needed to do some further configuration.
To start I changed the hosts by doing sudo nano /etc/hosts
and changed the loopback addresses.
To join to the domain again I ran the command sudo apt-get install krb5-user samba sssd sssd-tools libnss-sss libpam-sss ntp ntpdate realmd adcli
. I was then able to add AD01 as a administrative server.
After restarting ssh and editing the configuration file I was able to ssh in!
Docker
Using steps 1-3 of the rescoure linked in the lab I was able to install docker.
To start I made sure packages were updated using sudo apt update
.
I then ran the following commands to install docker:
#Allows apt to use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
#GPG key install
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
#Add docker to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
#Docker Install
sudo apt install docker-ce
sudo systemctl status docker
After I was able to run docker!
I then added Elizabeth-adm to docker by running sudo usermod -aG docker ${USER}
. I was able to confirm by running su elizabeth-adm
and then groups.
Install Docker Compose
Following the rescoure in the lab I needed to install the docker compose. To install I ran sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
, and then set the permissions using command sudo chmod +x /usr/local/bin/docker-compose
.
"Hello SYS265" Docker image
I then ran the command docker run --rm archlinux:latest /bin/echo "Hello SYS-265 NOT SO SNOWY DAYS"
to pull the Arch Linux command and then a echo to show my message.
Docker Arch Linux Container
For this section, I ran the below commands to see (from lab):
- current version of Ubuntu on docker01.
- current version of docker01's linux kernel.
- Invoke a container of the stored Ubuntu image as well as an interactive bash command prompt.
- the kernel being used by the Ubuntu container.
Docker Web Application
After looking into the containerization I was able to move on to the web installation. I ran the command docker run -d -P docker/getting-started
to install a simple Python web application.
Docker Networking
With the networking running I needed to configure my firewal. I first installed with sudo apt install firewalld
and then added my port using sudo firewall-cmd --permanent --add-port=32768/tcp
. I was then able to run docker ps