Docker Lab - lizzy9596/sys-265 GitHub Wiki

Docker Lab

The goal of this lab is to configure docker01 and gain experience using docker.

Parts:

  1. Configuration
  2. Install Docker
  3. Install Docker Compose
  4. "Hello SYS265" Docker image
  5. Docker Arch Linux Container
  6. Docker Web Application
  7. Docker Networking
  8. 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:

{10F4A504-A133-4A17-808B-A35DE3828AF0}

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.

{5C8314D8-63FA-41DE-AA20-2E4D188193B5}

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.

{AA506B49-B532-4A0B-801B-4463267BEC76}

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

{2741DC12-C44F-46EF-928C-666448C7FB0C}

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!

{A0E8A51E-CD79-427F-AE2D-DE3D60544865}

I then went into mgmt01 to update the DNS records with docker01. {FCE21F92-E5C7-4F58-9844-C1E612414121}

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.

{564B8929-F6B5-4D2A-9BDA-6BAFCAC0B1CC}

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. {6954CD10-ED7C-4E53-ABC7-BFC07537970A}

After restarting ssh and editing the configuration file I was able to ssh in! {8985AFF6-69A5-470B-BAFE-FC3351072A79}

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!

{246C6D14-A49A-42E8-B01A-DE34328F4CD0}

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.

{4A964C38-A85C-4808-B347-F890BCCC306F}

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.

{D7289D1C-CF7E-4B46-AF63-CCFA0CBCA6D9}

"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. {5463583A-34DE-4BC4-9956-CBC92108DCA1}

Docker Arch Linux Container

For this section, I ran the below commands to see (from lab):

  1. current version of Ubuntu on docker01.
  2. current version of docker01's linux kernel.
  3. Invoke a container of the stored Ubuntu image as well as an interactive bash command prompt.
  4. the kernel being used by the Ubuntu container.

{175EC55E-99BB-4E6D-998D-64AA8679141C}

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

Dockerized Wordpress