Mikey’s Linux Field NotesAll topics

GUIDE 17 / CONTAINERS

Docker

Inspect images, containers, published ports, and read-only host mounts.

3 quick lessons · Examples to adapt to your server
In this guide
Inspect containers and imagesUnderstand published portsKeep content on the host

Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.

01

Inspect containers and images

An image is a template; a container is a running or stopped instance of an image. Containers share the host kernel, while virtual machines run their own guest kernels.

COMMANDS & EXAMPLES
docker version
docker image ls
docker ps -a
docker logs --tail 20 hw8-public
docker port hw8-public 80
Field note

Access to the Docker daemon is highly privileged. A user in the docker group can effectively gain root access to the host. Container names must be unique, including stopped containers.

02

Understand published ports

127.0.0.1:8081 binds a host port only to loopback. A publication without a host IP usually binds all host interfaces. Docker may install DNAT and forwarding rules that make a port reachable independently of firewalld’s public-zone port list.

COMMANDS & EXAMPLES
docker ps --format "table {{.Names}}\t{{.Ports}}"
curl -I http://127.0.0.1:8081
curl -I http://localhost:8888
sudo nft list ruleset
Field note

In the class setup, hw8-local is loopback-only on 8081 and hw8-public is exposed on 8888. Do not flush nftables or edit Docker-managed tables to diagnose this.

03

Keep content on the host

A bind mount exposes a host directory inside a container. :ro prevents container processes from writing through that mount; you can still edit the host files normally.

COMMANDS & EXAMPLES
docker inspect hw8-public --format "{{json .Mounts}}"
docker exec hw8-public ls -l /usr/share/nginx/html
docker logs hw8-public 2>&1 | grep " 404 "
Field note

Both class web containers read ~/homework/week8/site. Host edits appear in both without rebuilding an image. Removing a container does not delete that bind-mounted host directory.