SYS‐265 DOCKER LAB - derek-hash/SYS-265-02 GitHub Wiki
In this lab, I configured a new Ubuntu 20.04 virtual machine (docker01) with a static IP, installed Docker, and set up a Python application within a Docker container. The lab required configuring networking via netplan, adding a new sudo user, and managing Docker containers for a Python web application.
To configure networking on my Ubuntu system, I edited the /etc/netplan/00-installer-config.yaml file. Initially, the file was set to DHCP, but I needed to configure it to use a static IP address of 10.0.5.12. After adding the necessary configurations, I applied the changes using the netplan apply command. I verified the static IP using ip addr show and confirmed connectivity with a ping to 10.0.5.2 (the gateway).
Challenges: I ran into a minor issue with YAML formatting in the netplan file. After fixing the indentation and correcting the gateway4 and nameservers entries, the network configuration worked as expected.
To create a new sudo user, I used the adduser command followed by usermod -aG sudo to add the user to the sudo group. I verified the group membership using the id command to ensure the user had the necessary permissions to run administrative tasks.
Challenges: Ubuntu’s group management differs slightly from CentOS, so I had to ensure the user was added to the correct group (sudo).
I installed Docker on my Ubuntu system by following the official installation guide. I verified the installation with docker --version and checked that the Docker service was running using systemctl status docker. I was able to run the docker run command to start a Python web app in a container.
Docker Commands:
docker ps: Shows the running containers. docker run -d -p 8080:80 python.app.py: Starts the container in detached mode, mapping port 8080 on the host to port 80 in the container. docker logs <container_id>: Displays logs for troubleshooting. 5. ## Networking and Docker I used the -p flag to map host ports to container ports. This was essential for making the web app accessible on the host machine. By running the container on port 8080 and exposing port 80 inside the container, I was able to access the app via http://localhost:8080.