H 151: Making a Custom Docker Container (10 pts)

What You Need for this Project

Purpose

To practice using Docker for simple tasks.

I am following this tutorial .

Installing Docker

Make sure your Linux machine has: On your Linux server, execute these commands, replacing "debian" in the third command with your username.

sudo apt update
sudo apt install curl docker.io -y
sudo usermod -aG docker debian
newgrp docker

Making a Custom Dockerfile

On your Linux server, execute these commands:

mkdir nmap-server
cd nmap-server
nano Dockerfile
Paste in the code below.

FROM debian
MAINTAINER YOURNAME
RUN apt-get update && \
    apt-get install -y nmap iproute2 && \
    apt-get clean
ENTRYPOINT ["/usr/bin/nmap"]
CMD ["-sn", "-v", "172.17.0.1-10"] 
# Scan docker network 172.17.0.1-10 for running containers
Your code should look like the image below.

Save the file with Ctrl+x, y, Enter.

Building the Image

On your Linux server, execute this command, replacing "yourname" with a version of your name using only lowercase letters and no spaces:

docker build -t yourname/nmap-server:1.0 .
Your build should succeed, as shown below.

Troubleshooting

If you get error messages like:

Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease Temporary failure resolving 'deb.debian.org'

Execute this command to restart Docker:

sudo service docker restart

Running a Container from your Image

On your Linux server, execute this command:

docker images
docker run yourname/nmap-server:1.0
The container runs an Nmap scan, as shown below.

Flag H 151.1: Viewing the Container (10 pts)

On your Linux server, execute this command:

docker ps -a
The flag is covered by a green rectangle in the image below.

Posted 3-8-25
Final image fixed 3-12-25
Video added 3-26-25