Skip to content

Full lab · 13 missions · about 90 minutes

Docker: the full lab

In the video, I put a small status page app in a container by hand, on a Linux server with no Docker: 28 commands. Then Docker does it with a five-line recipe and two commands, and we open its container to compare. Here, you do all of it yourself, on a server of your own.

Short on time? Start with the 10-minute exercise: the Docker half on your own computer, with no VM.

The card from the video: the row each mission builds by hand

Files

missions 2, 3 and 8

Processes

mission 4

Network

mission 5

Memory and CPU

mission 6

User

mission 7

Before you start

You need a Linux server with Ubuntu 26.04 and no Docker on it, where you can use sudo. Use a fresh one: the lab changes it as root. A free VM from Multipass, Canonical's tool that makes Ubuntu VMs on macOS, Windows and Linux, is just right. Install it, then on your computer:

multipass launch 26.04 --name server-1 --cpus 2 --memory 4G --disk 20G
multipass shell server-1

Now open a second terminal on your computer, and run multipass shell server-1 there too. The missions call them terminal 1 and terminal 2: terminal 1 runs the app, terminal 2 everything else. The prompt in both is ubuntu@server-1:~$, as in the video.

In terminal 2, get the lab from my tutorials repository on GitHub, and put the app where the video has it, in /app, with an empty /data for its log:

git clone --depth 1 --branch 284-docker-explained https://github.com/antonputra/tutorials.git
cd tutorials/lessons/284/lab
sudo mkdir -p /app /data
sudo cp app/status.py app/message.txt /app/
sudo chown $USER /data
  • The app is two files: status.py, a status page in Python, and message.txt, the text on the page. On each request, it reads the message, adds a line to /data/requests.log and sends the message back.
  • Run each command in terminal 2, unless a step says terminal 1. Run terminal 2's commands from the lab's folder, where git clone and cd put you.
  • Paste each block whole, with its copy button, and press Enter. If the lines after a sudo line don't run, paste them one at a time.
  • P=$(pgrep -n -f '^python3 /app/status') keeps the app's process number in P, for the next commands. Read it again each time the app starts.
  • Your process numbers, addresses, interface names, times and sizes will differ from the ones on this page. Mine come from a Mac with Apple silicon, so the server is arm64; on an x86_64 server, the libraries' folder is x86_64-linux-gnu, and the loader is /lib64/ld-linux-x86-64.so.2, so your folder has lib64 where mine has lib.

Mission 1. One process on one server

4 minutes

You start the app as a plain process, ask for its page, and see how much of the server it gets: the card's five rows.

  1. In terminal 1, start the app:

    python3 /app/status.py
    

    It stays there, listening on 127.0.0.1, port 8000, and prints a line for each request.

  2. In terminal 2, ask for the page, then look at the log:

    curl http://127.0.0.1:8000/status
    cat /data/requests.log
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    2026-11-18T12:03:07Z 127.0.0.1 GET /status
    

    The client's address is 127.0.0.1: the machine itself.

  3. The app is a process. See its number, its user and its memory:

    P=$(pgrep -n -f '^python3 /app/status')
    ps -o pid,user,rss,args -p $P
    
        PID USER       RSS COMMAND
      10321 ubuntu   22832 python3 /app/status.py
    

    RSS is its memory in kilobytes: about 22 MB.

  4. Now the card, row by row. Files: every folder in the server's root folder. Processes: every process on the server. Network: the server's own, where the app took port 8000:

    ls / | wc -l
    ps -e --no-headers | wc -l
    ip -br addr
    sudo ss -ltnp | grep 8000
    
    22
    121
    lo               UNKNOWN        127.0.0.1/8 ::1/128
    enp0s1           UP             192.168.252.11/24 metric 1024 ...
    LISTEN 0      5          127.0.0.1:8000      0.0.0.0:*    users:(("python3",pid=10321,fd=3))
    
  5. Memory and CPU: all of the server's. User: you, ubuntu, number 1000:

    free -m
    nproc
    grep -E '^(Uid|CapEff)' /proc/$P/status
    
                   total        used        free      shared  buff/cache   available
    Mem:            3892         450        2830           1         761        3442
    Swap:              0           0           0
    2
    Uid:    1000    1000    1000    1000
    CapEff: 0000000000000000
    
  6. Is Docker here? Not yet:

    docker ps
    

    You get Command 'docker' not found, with a hint how to install it. Don't install it: Docker comes in mission 9.

  7. Stop the app:

    kill $P
    

    In terminal 1, it ends, and the prompt comes back.

Why. The app is two small files, but as a plain process it sees every folder, every process and the whole network of the server, and it can use all of its memory and CPU. One bug in the app, or one attacker getting in, and far too much of the server is in reach. The next missions take that away, one row at a time.

Mission 2. A folder with nothing else

6 minutes

You give the app a folder of its own as its root folder, and add files to it until it runs.

  1. Make the folder, with our two files and an empty data folder:

    sudo mkdir -p /srv/status-files/app /srv/status-files/data
    sudo cp /app/status.py /app/message.txt /srv/status-files/app/
    find /srv/status-files
    
    /srv/status-files
    /srv/status-files/data
    /srv/status-files/app
    /srv/status-files/app/status.py
    /srv/status-files/app/message.txt
    
  2. In terminal 1, start the app with this folder as its root folder:

    sudo chroot /srv/status-files python3 /app/status.py
    
    chroot: failed to run command 'python3': No such file or directory (os error 2)
    

    chroot changes the root folder. Our folder has no Python.

  3. Copy Python in. It's one file:

    sudo mkdir -p /srv/status-files/usr/bin
    sudo cp /usr/bin/python3.14 /srv/status-files/usr/bin/python3
    
  4. In terminal 1, try again. You get the same error:

    sudo chroot /srv/status-files python3 /app/status.py
    

    Python is in the folder now. The error only names the program Linux tried to start: a different file is missing.

  5. See what Python needs, and copy all of it:

    ldd /usr/bin/python3.14
    for f in $(ldd /usr/bin/python3.14 | grep -o '/[^ ]*'); do sudo mkdir -p /srv/status-files$(dirname $f) && sudo cp -L $f /srv/status-files$f; done
    
        linux-vdso.so.1 (0x0000f8ce07b9c000)
        libm.so.6 => /usr/lib/aarch64-linux-gnu/libm.so.6 (0x0000f8ce07a90000)
        libz.so.1 => /usr/lib/aarch64-linux-gnu/libz.so.1 (0x0000f8ce07a50000)
        libexpat.so.1 => /usr/lib/aarch64-linux-gnu/libexpat.so.1 (0x0000f8ce07a00000)
        libc.so.6 => /usr/lib/aarch64-linux-gnu/libc.so.6 (0x0000f8ce07830000)
        /lib/ld-linux-aarch64.so.1 (0x0000f8ce07b60000)
    

    Four libraries, and the loader, the small program that brings them in. The first line isn't a file. The loop copies each file that ldd names to the same place in our folder.

  6. In terminal 1, try again:

    sudo chroot /srv/status-files python3 /app/status.py
    
    ...
    Fatal Python error: Failed to import encodings module
    Python runtime state: core initialized
    ModuleNotFoundError: No module named 'encodings'
    ...
    

    Python starts, and stops right away: a big part of Python is its own code, in plain files.

  7. Copy Python's own code in:

    du -sh /usr/lib/python3.14
    sudo mkdir -p /srv/status-files/usr/lib/python3.14
    sudo cp -a /usr/lib/python3.14/. /srv/status-files/usr/lib/python3.14/
    
    32M /usr/lib/python3.14
    
  8. In terminal 1, start the app once more. No error: it stays there, and runs.

    sudo chroot /srv/status-files python3 /app/status.py
    
  9. Ask for the page, and count what it took:

    curl http://127.0.0.1:8000/status
    sudo find /srv/status-files -type f | wc -l
    sudo du -sh /srv/status-files
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    1317
    42M /srv/status-files
    

Why. Our code is plain text, and Python runs it. Python needs its libraries, the loader that brings them in, and its own code, and Linux looks for each one in the root folder. So an app is its code and a lot more: over a thousand files and 42 MB, for two small files of our own. It needs a folder like ours on every server it runs on.

Mission 3. Inside its own tree

6 minutes

You look around from inside the folder, and see what the app can still reach.

  1. For the app, the tree of files begins at our folder:

    P=$(pgrep -n -f '^python3 /app/status')
    sudo readlink /proc/$P/root
    
    /srv/status-files
    

    When the app opens /app/message.txt, the kernel opens /srv/status-files/app/message.txt. Same name, same system call, new result.

  2. Look around from inside. ls is a program too, and our folder doesn't have it:

    sudo chroot /srv/status-files ls /
    
    chroot: failed to run command 'ls': No such file or directory (os error 2)
    
  3. Add one small file of basic commands, BusyBox, and look again:

    sudo mkdir -p /srv/status-files/bin /srv/status-files/proc
    sudo cp /usr/bin/busybox /srv/status-files/bin/
    sudo chroot /srv/status-files /bin/busybox --install -s /bin
    sudo chroot /srv/status-files ls /
    
    app
    bin
    data
    lib
    proc
    usr
    

    Six folders, not the server's 22. The server's own files are out of reach:

    sudo chroot /srv/status-files cat /etc/hostname
    cat /etc/hostname
    
    cat: can't open '/etc/hostname': No such file or directory
    server-1
    
  4. Your request from mission 2 went into the app's own data folder. If we throw the folder away, the log goes with it. So we make a folder we keep, outside, and mount it at the app's /data:

    sudo ls -l /srv/status-files/data
    sudo rm /srv/status-files/data/requests.log
    sudo mkdir /srv/status-keep
    sudo mount --bind /srv/status-keep /srv/status-files/data
    findmnt -o TARGET,SOURCE /srv/status-files/data
    
    total 4
    -rw-r--r-- 1 root root 43 Nov 18 12:03 requests.log
    TARGET                 SOURCE
    /srv/status-files/data /dev/sda1[/srv/status-keep]
    
    curl http://127.0.0.1:8000/status
    cat /srv/status-keep/requests.log
    

    The new log line is in the folder we keep.

  5. The app still runs as root, with all of root's powers, and with /proc in its folder it would see every process on the server:

    grep -E '^(Uid|CapEff)' /proc/$P/status
    sudo mount -t proc proc /srv/status-files/proc
    sudo chroot /srv/status-files ps | head -5
    sudo umount /srv/status-files/proc
    
    Uid:    0   0   0   0
    CapEff: 000001ffffffffff
    PID   USER     COMMAND
        1 0        /usr/lib/systemd/systemd --switched-root --system --deserialize=52
        2 0        [kthreadd]
        3 0        [pool_workqueue_]
        4 0        [kworker/R-rcu_g]
    
  6. From inside, root can even stop one of your own programs. Start one that only waits, and end it from inside the folder:

    sleep 600 &
    sudo chroot /srv/status-files kill $(pgrep -n -x sleep)
    pgrep -a -x sleep
    

    pgrep finds no sleep: it's gone. Your shell says Terminated for it too.

Why. chroot changes only where the app's tree of files begins. It's the same app, as root, sharing everything else with the server: its processes, its network, its memory. So the next missions add one wall at a time. The folder we keep is a bind mount: one folder shown in a second place, so the log lives outside the app's files.

Mission 4. Its own process list

6 minutes

You start the app with its own list of processes, a PID namespace, where it is process 1.

  1. Stop the app, the usual way:

    sudo kill $P
    
  2. In terminal 1, start it in new namespaces:

    sudo unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py
    

    unshare starts a program in new namespaces: --pid gives it its own list of processes, and --mount-proc its own /proc to read it from. --root does what chroot did.

  3. Ask for the page, and compare the two lists:

    curl http://127.0.0.1:8000/status
    P=$(pgrep -n -f '^python3 /app/status')
    ps -o pid,user,args -p $P
    sudo nsenter --target $P --all --root ps
    grep NSpid /proc/$P/status
    
        PID USER     COMMAND
      13793 root     python3 /app/status.py
    PID   USER     COMMAND
        1 0        python3 /app/status.py
        2 0        ps
    NSpid:  13793   1
    

    nsenter runs a command inside the app's namespaces, so ps sees its list: our app is process 1, and ps itself is 2. On the server, the same process is 13793. The app has two numbers.

  4. From inside, a process on the server is now out of reach:

    sleep 600 &
    sudo nsenter --target $P --all --root kill $(pgrep -n -x sleep)
    pgrep -a -x sleep
    kill $(pgrep -n -x sleep)
    
    [1] 14190
    kill: can't kill pid 14190: No such process
    14190 sleep 600
    

    The shell numbers the background sleep as job [1]. Inside, there's no process 14190. The last kill ends it from the server, and the shell says [1]+ Terminated, sometimes only after your next command.

  5. Try to stop the app with a plain kill, from inside and from the server:

    sudo nsenter --target $P --all --root kill -TERM 1
    sudo kill $P
    ps -o pid,args -p $P
    
        PID COMMAND
      13793 python3 /app/status.py
    

    It's still running. Process 1 of a namespace gets only the signals it asked for, and our app never asked for this one.

  6. The app still shares the server's network. A second copy can't start, because port 8000 is taken:

    sudo unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py 2>&1 | tail -3
    
        self.socket.bind(self.server_address)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
    OSError: [Errno 98] Address already in use
    
  7. Stop the app for good. Sent from the server, KILL always works, even on process 1:

    sudo kill -KILL $P
    

Why. A namespace changes what a process can see. In its own PID namespace, the app sees only itself, and the kernel keeps a second number for it there. Process 1 is special in Linux: it ignores a signal unless it asked for it. Docker's containers have the same trap, as you'll see in mission 11.

Mission 5. Its own network

7 minutes

You give the app a network of its own, a network namespace, and connect it to the server with a cable: a pair of virtual interfaces.

  1. Make a network namespace. It has one interface, and it's down:

    sudo ip netns add status
    ip netns list
    sudo ip netns exec status ip -br addr
    
    status
    lo               DOWN
    
  2. In terminal 1, start the app in it:

    sudo ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py
    
  3. The server can't reach it anymore:

    curl -sS -m 5 http://127.0.0.1:8000/status
    
    curl: (7) Failed to connect to 127.0.0.1 port 8000 after 0 ms: Could not connect to server
    
  4. Make the cable, a pair of virtual interfaces, and move one end into the app's network:

    sudo ip link add veth-server type veth peer name veth-app
    sudo ip link set veth-app netns status
    ip -br link | grep veth
    sudo ip netns exec status ip -br link
    
    veth-server@if3  DOWN           a6:73:21:59:b0:d0 <BROADCAST,MULTICAST>
    lo               DOWN           00:00:00:00:00:00 <LOOPBACK>
    veth-app@if4     DOWN           ba:d7:1d:b0:0b:9b <BROADCAST,MULTICAST>
    
  5. Give each end an address, and turn them on:

    sudo ip addr add 10.0.0.1/24 dev veth-server
    sudo ip link set veth-server up
    sudo ip netns exec status ip addr add 10.0.0.2/24 dev veth-app
    sudo ip netns exec status ip link set veth-app up
    sudo ip netns exec status ip link set lo up
    sudo ip netns exec status ip -br addr
    
    lo               UNKNOWN        127.0.0.1/8 ::1/128
    veth-app@if4     UP             10.0.0.2/24 fe80::b8d7:1dff:feb0:b9b/64
    
  6. The cable works, but the page still doesn't:

    ping -c 1 10.0.0.2
    curl -sS -m 5 http://10.0.0.2:8000/status
    sudo ip netns exec status ss -ltn
    
    PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
    64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.019 ms
    
    --- 10.0.0.2 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.019/0.019/0.019/0.000 ms
    curl: (7) Failed to connect to 10.0.0.2 port 8000 after 0 ms: Could not connect to server
    State  Recv-Q Send-Q Local Address:Port Peer Address:Port
    LISTEN 0      5          127.0.0.1:8000      0.0.0.0:*
    

    The app listens only on 127.0.0.1, its own network's machine-itself address, and our request comes in on 10.0.0.2.

  7. Stop the app:

    P=$(pgrep -n -f '^python3 /app/status')
    sudo kill -KILL $P
    
  8. In terminal 1, start it again, listening on every address of its network:

    sudo ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py --listen 0.0.0.0
    
  9. Ask for the page at the app's address, and look at the log:

    curl -i http://10.0.0.2:8000/status
    tail -1 /srv/status-keep/requests.log
    
    HTTP/1.0 200 OK
    Server: BaseHTTP/0.6 Python/3.14.4
    ...
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    2026-11-18T12:03:49Z 10.0.0.1 GET /status
    

    The client is 10.0.0.1 now: the server, at its end of the cable.

  10. The app has three namespaces of its own now, mnt, net and pid. The rest it still shares with the server:

    P=$(pgrep -n -f '^python3 /app/status')
    sudo lsns -p $P
    

Why. A network namespace starts with nothing in it, not even a working lo. The veth pair is two interfaces joined like a cable: what goes in one end comes out of the other. 10.0.0.x is a range kept for private networks, so these addresses can't clash with the internet.

Extra: two apps, one port

Open terminal 3 on your computer (multipass shell server-1), and start a second copy there, in the server's own network. In terminal 3:

sudo unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py

Then in terminal 2, both answer on port 8000, each in its own network:

curl http://127.0.0.1:8000/status
curl http://10.0.0.2:8000/status
sudo ss -ltn | grep 8000
sudo ip netns exec status ss -ltn | grep 8000
sudo kill -KILL $(pgrep -n -f '^python3 /app/status')

The last command stops the second copy, the newest.

Mission 6. A limit

7 minutes

You turn on the app's memory leak, and put the app in a control group that limits its memory and CPU.

  1. Stop the app, and make a control group: a folder, which Linux fills with files right away:

    sudo kill -KILL $P
    sudo mkdir /sys/fs/cgroup/status
    ls /sys/fs/cgroup/status | wc -l
    cat /sys/fs/cgroup/status/memory.max
    
    50
    max
    

    max means no limit, yet.

  2. In terminal 1, start the app in the group, with its leak on, 10 MB more on every request:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py --listen 0.0.0.0 --leak-mb 10'
    

    The small shell writes its own process number, $$, into the group's cgroup.procs, and exec turns it into the start command. So the app starts in the group.

  3. Send eight requests, and read the group's memory meter after each one:

    for i in 1 2 3 4 5 6 7 8; do curl -s -o /dev/null -w "request $i: HTTP %{http_code}, " -m 5 http://10.0.0.2:8000/status; echo "memory.current $(cat /sys/fs/cgroup/status/memory.current)"; done
    
    request 1: HTTP 200, memory.current 24506368
    request 2: HTTP 200, memory.current 34992128
    ...
    request 8: HTTP 200, memory.current 97898496
    

    Eight answers, and almost 100 MB. Only the server's memory would stop it.

  4. Stop it, and set a limit of 64 MB:

    sudo kill -KILL $(pgrep -n -f '^python3 /app/status')
    echo 64M | sudo tee /sys/fs/cgroup/status/memory.max
    cat /sys/fs/cgroup/status/memory.max
    
    64M
    67108864
    
  5. In terminal 1, start the same app again, the leak still on:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py --listen 0.0.0.0 --leak-mb 10'
    
  6. The same eight requests:

    for i in 1 2 3 4 5 6 7 8; do curl -s -o /dev/null -w "request $i: HTTP %{http_code}, " -m 5 http://10.0.0.2:8000/status; echo "memory.current $(cat /sys/fs/cgroup/status/memory.current)"; done
    
    request 1: HTTP 200, memory.current 23695360
    ...
    request 5: HTTP 200, memory.current 65638400
    request 6: HTTP 000, memory.current 348160
    request 7: HTTP 000, memory.current 348160
    request 8: HTTP 000, memory.current 24576
    

    Request 6 gets no answer. In terminal 1, the app is gone.

  7. Linux killed it. The group counts it, and the kernel's log names it:

    grep oom_kill /sys/fs/cgroup/status/memory.events
    sudo dmesg | grep "Memory cgroup out of memory"
    free -m
    
    oom_kill 1
    [  212.911752] Memory cgroup out of memory: Killed process 17369 (python3) total-vm:85660kB, anon-rss:65100kB, ...
    

    OOM is short for out of memory. free -m shows that most of the server's memory is still free: a limit isn't a reservation.

  8. The same group limits CPU time. Run a small busy program in the group, before and after a limit of 50 ms in every 100 ms, and compare the times it was paused:

    time sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec python3 -c "sum(range(200000000))"'
    grep nr_throttled /sys/fs/cgroup/status/cpu.stat
    echo "50000 100000" | sudo tee /sys/fs/cgroup/status/cpu.max
    time sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec python3 -c "sum(range(200000000))"'
    grep nr_throttled /sys/fs/cgroup/status/cpu.stat
    
    real    0m0.817s
    user    0m0.813s
    sys 0m0.001s
    nr_throttled 0
    50000 100000
    
    real    0m2.153s
    user    0m0.859s
    sys 0m0.001s
    nr_throttled 17
    

    Without the limit, Linux paused it 0 times. With it, 17 times on my server, as in the video; your count depends on your CPU's speed. Either way, the same work took longer: compare the two real lines.

  9. In terminal 1, start the app in the group, without the leak:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files python3 /app/status.py --listen 0.0.0.0'
    
    curl http://10.0.0.2:8000/status
    cat /sys/fs/cgroup/status/memory.current
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    12828672
    

    About 12 MB, well under the limit.

Why. A namespace changes how much a process sees, not how much it uses. A control group, cgroup for short, is a group of processes measured and limited as a unit, and Linux shows each one as a folder. Every process the app starts joins its group too. The CPU limit is a time budget on the shared CPUs: at most 50 ms in every 100 ms, half a CPU, and when the group has used it, Linux pauses it until the next 100 ms begins.

Mission 7. Not root

5 minutes

You see what root inside can do, and start the app as a user of its own.

  1. The app still runs as root, and root inside shares too much. Rename the server from inside, then put the name back:

    P=$(pgrep -n -f '^python3 /app/status')
    grep -E '^(Uid|CapEff)' /proc/$P/status
    hostname
    sudo nsenter --target $P --all --root hostname broken
    hostname
    sudo hostname $(cat /etc/hostname)
    hostname
    
    Uid:    0   0   0   0
    CapEff: 000001ffffffffff
    server-1
    broken
    server-1
    

    The server's name isn't in the app's namespaces, so root inside changed it for the whole server. The name in /etc/hostname stayed, so we put it back from there.

  2. Stop the app, and make a user for it, number 10001, with no home and no shell:

    sudo kill -KILL $P
    sudo useradd --uid 10001 --no-create-home --shell /usr/sbin/nologin status
    id status
    
    uid=10001(status) gid=10001(status) groups=10001(status)
    
  3. In terminal 1, start the app as that user:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files --setuid 10001 --setgid 10001 python3 /app/status.py --listen 0.0.0.0'
    
  4. It has none of root's powers now, so it can't rename the server:

    P=$(pgrep -n -f '^python3 /app/status')
    ps -o pid,user,args -p $P
    grep -E '^(Uid|CapEff)' /proc/$P/status
    sudo nsenter --target $P --all --root --setuid 10001 --setgid 10001 hostname broken
    
        PID USER     COMMAND
      18774 status   python3 /app/status.py --listen 0.0.0.0
    Uid:    10001   10001   10001   10001
    CapEff: 0000000000000000
    hostname: sethostname: Operation not permitted
    
  5. But the page breaks:

    curl -sS -m 5 http://10.0.0.2:8000/status
    ls -l /srv/status-keep
    
    curl: (52) Empty reply from server
    total 4
    -rw-r--r-- 1 root root 801 Nov 18 12:04 requests.log
    

    In terminal 1, the app says why: PermissionError: [Errno 13] Permission denied: '/data/requests.log'. The log belongs to root.

  6. Give the folder we keep to the app's user, and ask again:

    sudo chown -R 10001:10001 /srv/status-keep
    curl http://10.0.0.2:8000/status
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    

Why. Root's powers are split into capabilities, and CapEff shows the ones a process can use: all ones for root, all zeros for our user. A user that owns nothing on the server can't break anything on it, but it must own what the app writes. That's the price, and Docker images pay it too: a USER line, and a /data that belongs to that user.

Mission 8. One folder, clean every time

8 minutes

You change a file inside, see the change stay, and fix that with stacked folders: an overlay.

  1. Change the message from inside, as root:

    sudo nsenter --target $P --all --root sh -c 'echo "Status: MAINTENANCE" > /app/message.txt'
    curl http://10.0.0.2:8000/status
    sudo kill -KILL $P
    
    <!doctype html><title>Status</title><h1>Status: MAINTENANCE</h1>
    
  2. In terminal 1, start the app again, the same way:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-files --setuid 10001 --setgid 10001 python3 /app/status.py --listen 0.0.0.0'
    
  3. The change is still there, because it was made in our own files:

    curl http://10.0.0.2:8000/status
    cat /srv/status-files/app/message.txt
    echo 'Status: OK' | sudo tee /srv/status-files/app/message.txt
    
    <!doctype html><title>Status</title><h1>Status: MAINTENANCE</h1>
    Status: MAINTENANCE
    Status: OK
    
  4. Stop the app, and stack the folders: our files at the bottom, an empty folder on top, and one merged folder for the app. Then mount the folder we keep at the merged folder's /data:

    sudo kill -KILL $(pgrep -n -f '^python3 /app/status')
    sudo umount /srv/status-files/data
    sudo mkdir -p /srv/status-1/top /srv/status-1/work /srv/status-1/merged
    sudo mount -t overlay overlay -o lowerdir=/srv/status-files,upperdir=/srv/status-1/top,workdir=/srv/status-1/work /srv/status-1/merged
    sudo mount --bind /srv/status-keep /srv/status-1/merged/data
    findmnt -t overlay -o TARGET,FSTYPE,OPTIONS
    ls /srv/status-1/merged
    
    TARGET               FSTYPE  OPTIONS
    /srv/status-1/merged overlay rw,relatime,lowerdir=/srv/status-files,upperdir=/srv/status-1/top,workdir=/srv/status-1/work,uuid=on,nouserxattr
    app
    bin
    data
    lib
    proc
    usr
    

    lowerdir is the bottom, upperdir the top. workdir is scratch space the kernel needs.

  5. In terminal 1, start the app with the merged folder as its root folder. This is the 28th command of the video:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-1/merged --setuid 10001 --setgid 10001 python3 /app/status.py --listen 0.0.0.0'
    
  6. Make the same change. This time it lands in the top folder, and our files stay as they were:

    P=$(pgrep -n -f '^python3 /app/status')
    sudo nsenter --target $P --all --root sh -c 'echo "Status: MAINTENANCE" > /app/message.txt'
    curl http://10.0.0.2:8000/status
    cat /srv/status-files/app/message.txt
    sudo find /srv/status-1/top -type f
    
    <!doctype html><title>Status</title><h1>Status: MAINTENANCE</h1>
    Status: OK
    /srv/status-1/top/app/message.txt
    
  7. Throw the top folder away, and stack a clean one:

    sudo kill -KILL $P
    sudo umount /srv/status-1/merged/data /srv/status-1/merged
    sudo rm -rf /srv/status-1/top /srv/status-1/work
    sudo mkdir /srv/status-1/top /srv/status-1/work
    sudo mount -t overlay overlay -o lowerdir=/srv/status-files,upperdir=/srv/status-1/top,workdir=/srv/status-1/work /srv/status-1/merged
    sudo mount --bind /srv/status-keep /srv/status-1/merged/data
    
  8. In terminal 1, start the app the same way as in step 5:

    sudo sh -c 'echo $$ > /sys/fs/cgroup/status/cgroup.procs && exec ip netns exec status unshare --pid --fork --mount-proc --root=/srv/status-1/merged --setuid 10001 --setgid 10001 python3 /app/status.py --listen 0.0.0.0'
    
  9. It's clean again. Now check the whole card at once with the lab's check.sh: 14 checks of the five rows:

    curl http://10.0.0.2:8000/status
    ./check.sh
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    ok    the app runs: process 20747 on the server
    ok    the page answers at 10.0.0.2:8000
    ok    nothing listens on the server's own port 8000
    ok    its root folder is /srv/status-1/merged
    ok    that folder is stacked: our files below, a top folder above
    ok    inside, it is process 1 (NSpid: 20747 1)
    ok    inside, ps lists one python3
    ok    it is in the group /status
    ok    memory.max is 67108864
    ok    cpu.max is 50000 100000
    ok    it runs as user 10001 (status)
    ok    it has none of root's powers
    ok    the request is in /srv/status-keep/requests.log
    ok    its own namespaces: mnt, net and pid
    0 failed
    

Why. An overlay shows the folders stacked as one. The app reads through the top folder to our files below, and a change is copied up into the top folder first: copy-on-write. Throw the top away, and the next start is clean, while our files and the folder we keep never change. That's a container by hand: 28 commands. The lab's build.sh holds the first 27, the clean way, and launch.sh the 28th.

Extra: all 28 commands in one go

clean.sh takes everything apart, and build.sh puts it back, the way the video's list does it. In terminal 2:

./clean.sh
./build.sh

In terminal 1, start the app with launch.sh, the 28th command:

~/tutorials/lessons/284/lab/launch.sh

Then, in terminal 2, check it again. It passes all 14 checks:

./check.sh

Mission 9. Pack it: the image

8 minutes

You install Docker, and build an image from your own files with the video's five-line recipe.

  1. Install Docker Engine from Docker's own package repository, as Docker's install page says. Our container keeps running:

    ./install-docker.sh
    curl http://10.0.0.2:8000/status
    
    ...
    containerd.io   2.4.2-4~ubuntu.26.04~resolute
    docker-buildx-plugin    0.39.0-1~ubuntu.26.04~resolute
    docker-ce   5:29.10.0-1~ubuntu.26.04~resolute
    docker-ce-cli   5:29.10.0-1~ubuntu.26.04~resolute
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    
  2. Get the image's files ready: our app in a build folder, the recipe next to it, and every other file of our folder in one archive. The image's /data must belong to the app's user, because Docker copies its owner to a new volume:

    sudo chown 10001:10001 /srv/status-files/data
    sudo mkdir -p /srv/status-build/app
    sudo cp /app/status.py /app/message.txt /srv/status-build/app/
    sudo cp Dockerfile /srv/status-build/
    sudo tar -C /srv/status-files --exclude=./app -cf /srv/status-build/python-files.tar .
    cat /srv/status-build/Dockerfile
    
    FROM scratch
    ADD python-files.tar /
    COPY app/ /app/
    USER 10001:10001
    CMD ["python3", "/app/status.py", "--listen", "0.0.0.0"]
    

    FROM scratch means no base image: the image starts empty, like our folder in mission 2.

  3. Build it, and look at its layers:

    cd /srv/status-build
    sudo docker build -t status:1.0 .
    sudo docker image history status:1.0
    sudo docker image inspect status:1.0 --format '{{.Config.User}} {{json .Config.Cmd}}'
    
    IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
    94484f36f683   1 second ago   CMD ["python3" "/app/status.py" "--listen" "…   0B        buildkit.dockerfile.v0
    <missing>      1 second ago   USER 10001:10001                                0B        buildkit.dockerfile.v0
    <missing>      1 second ago   COPY app/ /app/ # buildkit                      16.4kB    buildkit.dockerfile.v0
    <missing>      1 second ago   ADD python-files.tar / # buildkit               45.4MB    buildkit.dockerfile.v0
    10001:10001 ["python3","/app/status.py","--listen","0.0.0.0"]
    

    Two layers of files, our folder and our app, and two settings: the user and the start command.

  4. Change the message, and build version 1.1:

    echo "Status: all systems normal" | sudo tee /srv/status-build/app/message.txt
    sudo docker build -t status:1.1 .
    sudo docker image ls status
    
    Status: all systems normal
    ...
    IMAGE        ID             DISK USAGE   CONTENT SIZE   EXTRA
    status:1.0   94484f36f683       60.2MB         14.9MB
    status:1.1   1619f9b0d7d0       60.2MB         14.9MB
    

    In the build's output, the big layer says CACHED: Docker built only the small one again. Each image lists 60.2MB, the big layer included, but the server stores that layer once.

  5. Go back to the lab's folder:

    cd ~/tutorials/lessons/284/lab
    

Why. An image is our folder, packed: its files as layers, plus the settings to start it. A layer is stored once and shared, so version 1.1 adds only our app's few kilobytes, and a server that has version 1.0 downloads only the new layer.

Extra: a registry

A registry stores images for other servers to download. Run one, as a container:

sudo docker run -d --name registry -p 127.0.0.1:5000:5000 registry:3

Then push both versions to it:

sudo docker tag status:1.0 localhost:5000/status:1.0
sudo docker push localhost:5000/status:1.0
sudo docker tag status:1.1 localhost:5000/status:1.1
sudo docker push localhost:5000/status:1.1
curl http://127.0.0.1:5000/v2/status/tags/list

The second push says Layer already exists for the big layer, and the registry lists both tags: {"name":"status","tags":["1.0","1.1"]}.

Mission 10. One command

5 minutes

You start the app with Docker: one command for the five things you did by hand.

  1. Run it: a name, a memory limit, half a CPU, a port on the server's 127.0.0.1, and a volume for the log:

    time sudo docker run -d --name status --memory 64m --cpus 0.5 -p 127.0.0.1:8080:8000 -v status-data:/data status:1.0
    
    1c8efae9d5cc4882d6f1aa4e3e9754e8f9a040bdbaf61a6138b9fb33ca1fa04f
    
    real    0m0.101s
    ...
    

    A tenth of a second. Ask for the page, and read what the app printed:

    curl http://127.0.0.1:8080/status
    sudo docker logs status
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    172.17.0.1 - - [18/Nov/2026 12:06:31] "GET /status HTTP/1.1" 200 -
    

    The client is 172.17.0.1: Docker's own bridge, docker0. The time is in UTC.

  2. Who carries your request to port 8000 inside:

    ip -br addr show docker0
    sudo ss -ltnp | grep 8080
    
    docker0          UP             172.17.0.1/16 ...
    LISTEN 0      4096       127.0.0.1:8080       0.0.0.0:*    users:(("docker-proxy",pid=30577,fd=7))
    

    docker-proxy is a forwarding program: it listens on the server's port 8080, and passes each request on to the container.

  3. What's left running for the container:

    D=$(sudo docker inspect status --format '{{.State.Pid}}')
    ps -o pid,ppid,user,args -p $D
    ps -o pid,args -p $(ps -o ppid= -p $D)
    pgrep -x runc
    
        PID    PPID USER     COMMAND
      30632   30607 status   python3 /app/status.py --listen 0.0.0.0
        PID COMMAND
      30607 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 1c8efae9d5cc... -address /run/containerd/containerd.sock
    

    docker asked Docker Engine, which asked containerd, which ran runc. runc set up the container and is gone: pgrep finds nothing. A small watcher, the shim, stays as the app's parent.

  4. Both apps, side by side, ours and Docker's:

    ps -o pid,user,args -p $(pgrep -d, -f '^python3 /app/status')
    
        PID USER     COMMAND
      20747 status   python3 /app/status.py --listen 0.0.0.0
      30632 status   python3 /app/status.py --listen 0.0.0.0
    

    The same line twice: only the number is different.

  5. Docker sets only the limits you ask for. A container started with no --memory gets none:

    ID=$(sudo docker run -d status:1.0)
    cat /sys/fs/cgroup/system.slice/docker-$ID.scope/memory.max
    sudo docker rm -f $ID
    
    max
    
  6. Everything Docker set up for status is in one settings file, config.json, the file runc read:

    ID=$(sudo docker inspect status --format '{{.Id}}')
    sudo ls -l /run/containerd/io.containerd.runtime.v2.task/moby/$ID/config.json
    

Why. docker run does the same five things you did by hand: a stacked folder from the image, a namespace for each list, a control group with the limits, the user, and a network with a port. The work is split among programs: docker only asks, Docker Engine and containerd prepare, and runc makes the container from config.json and exits.

Mission 11. Stop it, remove it, keep the data

6 minutes

You change the container, stop it, remove it, and see what stays.

  1. Change the message inside, as root, and see what changed:

    sudo docker exec --user 0 status sh -c 'echo "Status: MAINTENANCE" > /app/message.txt'
    curl http://127.0.0.1:8080/status
    sudo docker diff status
    
    <!doctype html><title>Status</title><h1>Status: MAINTENANCE</h1>
    C /app
    C /app/message.txt
    

    C is for changed, in the container's top folder.

  2. Stop it:

    time sudo docker stop status
    sudo docker ps -a --filter name=status --format "table {{.Names}}\t{{.Status}}"
    
    status
    
    real    0m10.129s
    ...
    NAMES     STATUS
    status    Exited (137) Less than a second ago
    

    Ten seconds. Docker sent the usual signal, our app ignored it as process 1, like in mission 4, and after 10 seconds Docker killed it. 137 means stopped by force.

  3. Start it again:

    sudo docker start status
    

    It's the same container, with the same top folder:

    sudo docker exec status ps
    curl http://127.0.0.1:8080/status
    
    PID   USER     COMMAND
        1 10001    python3 /app/status.py --listen 0.0.0.0
        8 10001    ps
    <!doctype html><title>Status</title><h1>Status: MAINTENANCE</h1>
    
  4. Remove it, and run a new one from the image:

    sudo docker rm -f status
    sudo docker run -d --name status --memory 64m --cpus 0.5 -p 127.0.0.1:8080:8000 -v status-data:/data status:1.0
    

    Ask the new one for the page, and read the log in the volume:

    curl http://127.0.0.1:8080/status
    sudo cat /var/lib/docker/volumes/status-data/_data/requests.log
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
    2026-11-18T12:06:31Z 172.17.0.1 GET /status
    2026-11-18T12:06:32Z 172.17.0.1 GET /status
    2026-11-18T12:06:43Z 172.17.0.1 GET /status
    2026-11-18T12:06:44Z 172.17.0.1 GET /status
    

    A clean start, and the log is still there: the volume is Docker's folder we keep.

  5. Now with --init: Docker starts a tiny program as process 1, and it starts our app and passes signals on:

    sudo docker rm -f status
    sudo docker run -d --init --name status --memory 64m --cpus 0.5 -p 127.0.0.1:8080:8000 -v status-data:/data status:1.0
    

    Look inside, and stop it:

    sudo docker exec status ps
    time sudo docker stop status
    sudo docker ps -a --filter name=status --format "table {{.Names}}\t{{.Status}}"
    
    PID   USER     COMMAND
        1 10001    /sbin/docker-init -- python3 /app/status.py --listen 0.0.0.0
        7 10001    python3 /app/status.py --listen 0.0.0.0
        8 10001    ps
    status
    
    real    0m0.064s
    ...
    NAMES     STATUS
    status    Exited (143) Less than a second ago
    

    It stops at once. 143 means stopped by the usual signal.

  6. Run it again the plain way, for the next missions:

    sudo docker rm status
    sudo docker run -d --name status --memory 64m --cpus 0.5 -p 127.0.0.1:8080:8000 -v status-data:/data status:1.0
    

    Then ask for the page:

    curl http://127.0.0.1:8080/status
    

Why. A container is a top folder over the image, like ours in mission 8. Stop and start keep it, and docker rm throws it away, so the next container starts clean. What must stay goes in a volume. Process 1 ignores signals it didn't ask for, in Docker too, so a real app either handles them or runs with --init.

Mission 12. Open it: the same parts

6 minutes

You open Docker's container and fill the card's second column, row by row, with the commands you used on your own.

  1. Docker's app is a process on the server too. Find it, and read the values you know from config.json (jq picks them out of the file):

    D=$(sudo docker inspect status --format '{{.State.Pid}}')
    ID=$(sudo docker inspect status --format '{{.Id}}')
    sudo jq '{args: .process.args, user: .process.user.uid, namespaces: [.linux.namespaces[].type], memory: .linux.resources.memory.limit, cpu: .linux.resources.cpu}' /run/containerd/io.containerd.runtime.v2.task/moby/$ID/config.json
    
    {
      "args": [
        "python3",
        "/app/status.py",
        "--listen",
        "0.0.0.0"
      ],
      "user": 10001,
      "namespaces": [
        "mount",
        "network",
        "time",
        "uts",
        "pid",
        "ipc",
        "cgroup"
      ],
      "memory": 67108864,
      "cpu": {
        "quota": 50000,
        "period": 100000
      }
    }
    
  2. Files: stacked folders, as in mission 8. Three at the bottom, and one on top for this container:

    sudo grep ' / / ' /proc/$D/mountinfo | grep -o -E '(lowerdir|upperdir)=[^,]*' | tr ':' '\n'
    sudo nsenter --target $D --all --root ls /
    
    lowerdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/33/fs
    /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/9/fs
    /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/8/fs
    upperdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/34/fs
    app
    bin
    data
    dev
    etc
    lib
    proc
    sys
    usr
    

    The lowest two are the image's layers: Python's files, and our app. The one above them is Docker's own: the files every container gets, such as /etc/hosts, /etc/hostname, /etc/resolv.conf, /dev and /sys. That's why ls / shows dev, etc and sys.

  3. Processes: its own list, where it is process 1:

    grep NSpid /proc/$D/status
    sudo nsenter --target $D --all --root ps
    
    NSpid:  33317   1
    PID   USER     COMMAND
        1 10001    python3 /app/status.py --listen 0.0.0.0
        8 0        ps
    
  4. Network: its own, with one end of a veth pair inside, eth0, and the other end on Docker's bridge:

    sudo nsenter --target $D --all --root ip addr show eth0
    bridge link
    
    2: eth0@if17: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
        link/ether 06:e2:30:ab:27:78 brd ff:ff:ff:ff:ff:ff
        inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0
           valid_lft forever preferred_lft forever
    6: veth99df5ea@enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master docker0 state forwarding priority 32 cost 2
    17: veth023aef9@enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master docker0 state forwarding priority 32 cost 2
    

    Inside, eth0@if17: its other end is interface 17 on the server, and bridge link shows 17 on Docker's bridge, docker0. The other line is the registry's container, if you ran it.

  5. Memory and CPU: its own control group, with your two limits:

    cat /proc/$D/cgroup
    cat /sys/fs/cgroup/system.slice/docker-$ID.scope/memory.max /sys/fs/cgroup/system.slice/docker-$ID.scope/cpu.max
    
    0::/system.slice/docker-969c6d9039e8c2f75b8fe719cb48e070dc181dae399ae0d7cece600d7eff2cf4.scope
    67108864
    50000 100000
    

    The same leak as in mission 6, in Docker, ends the same way. Start a second container with the leak on. The command after the image name replaces its start command, and --memory-swap 64m keeps swap out of it, on a server that has swap:

    sudo docker run -d --name leaky --memory 64m --memory-swap 64m -p 127.0.0.1:8082:8000 status:1.0 python3 /app/status.py --listen 0.0.0.0 --leak-mb 10
    

    Send it eight requests:

    for i in 1 2 3 4 5 6 7 8; do curl -s -o /dev/null -w "request $i: HTTP %{http_code}\n" -m 5 http://127.0.0.1:8082/status; done
    
    request 1: HTTP 200
    request 2: HTTP 200
    request 3: HTTP 200
    request 4: HTTP 200
    request 5: HTTP 200
    request 6: HTTP 000
    request 7: HTTP 000
    request 8: HTTP 000
    

    Then see how it ended, read the kernel's log, and remove it:

    sudo docker ps -a --filter name=leaky --format '{{.Names}}: {{.Status}}'
    sudo dmesg | grep "Memory cgroup out of memory" | tail -1
    sudo docker rm leaky
    
    leaky: Exited (137) 3 seconds ago
    [  430.752661] Memory cgroup out of memory: Killed process 24677 (python3) total-vm:84828kB, anon-rss:64868kB, file-rss:6648kB, shmem-rss:0kB, UID:10001 pgtables:188kB oom_score_adj:0
    leaky
    

    Requests 1 to 5 answer, 6 to 8 don't. Exited (137) means killed by force, and the kernel's last line names the process it killed: Docker's app, as user 10001.

  6. User: ours, 10001, with none of root's powers:

    ps -o pid,user,args -p $D
    grep -E '^(Uid|CapEff)' /proc/$D/status
    
        PID USER     COMMAND
      33317 status   python3 /app/status.py --listen 0.0.0.0
    Uid:    10001   10001   10001   10001
    CapEff: 0000000000000000
    
  7. Three apps have written logs by now. Each one's /data/requests.log is a different file on the server:

    sudo tail -n 1 /data/requests.log /srv/status-keep/requests.log /var/lib/docker/volumes/status-data/_data/requests.log
    

    The clients: 127.0.0.1, 10.0.0.1 and 172.17.0.1.

Why. Every row of Docker's column holds the same Linux parts you used by hand: an overlay, namespaces, a control group, a user and a veth pair. Docker found them in your image and your docker run, wrote them into config.json, and runc asked the kernel for each one.

Mission 13. What Docker adds

6 minutes

You compare the two containers, and see what Docker does that our 28 commands don't.

  1. Ours has three namespaces of its own. Docker's has seven:

    H=$(pgrep -o -f '^python3 /app/status')
    D=$(sudo docker inspect status --format '{{.State.Pid}}')
    sudo lsns -p $H
    sudo lsns -p $D
    

    uts is one of Docker's extra four: the server's name. So Docker's container has a name of its own:

    hostname
    sudo nsenter --target $H --all --root hostname
    sudo docker exec status hostname
    
    server-1
    server-1
    969c6d9039e8
    
  2. Root inside ours renamed the server in mission 7. Inside Docker's, root can't:

    sudo docker exec --user 0 status hostname broken
    sudo docker exec --user 0 status date -s "2030-01-01 00:00:00"
    hostname
    sudo docker exec status date
    
    hostname: sethostname: Operation not permitted
    date: can't set date: Operation not permitted
    Tue Jan  1 00:00:00 UTC 2030
    server-1
    Wed Nov 18 12:07:07 UTC 2026
    

    BusyBox's date still prints the time it was given, but the clock didn't change: the last line is today's date. The container has no time zone of its own, so it shows UTC.

  3. Docker gives root inside only some powers, and a filter of system calls. Compare the two apps:

    grep -E '^(CapBnd|Seccomp):' /proc/$H/status
    grep -E '^(CapBnd|Seccomp):' /proc/$D/status
    
    CapBnd: 000001ffffffffff
    Seccomp:    0
    CapBnd: 00000000a80425fb
    Seccomp:    2
    

    CapBnd is the most any process inside may get: all 41 powers for ours, 14 for Docker's. Seccomp: 2 means a filter checks every system call.

  4. One kernel, for the server and both containers:

    uname -r
    sudo nsenter --target $H --all --root uname -r
    sudo docker exec status uname -r
    
    7.0.0-43-generic
    7.0.0-43-generic
    7.0.0-43-generic
    
  5. A second container from the same image takes one command, and shares its layers:

    sudo docker run -d --name status2 --memory 64m --cpus 0.5 -p 127.0.0.1:8081:8000 status:1.0
    

    Ask it for the page, and list the apps and the containers:

    curl http://127.0.0.1:8081/status
    ps -o pid,user,args -p $(pgrep -d, -f '^python3 /app/status')
    sudo docker ps -s --filter name=status --format "table {{.Names}}\t{{.Size}}"
    
    <!doctype html><title>Status</title><h1>Status: OK</h1>
        PID USER     COMMAND
      20747 status   python3 /app/status.py --listen 0.0.0.0
      33317 status   python3 /app/status.py --listen 0.0.0.0
      35545 status   python3 /app/status.py --listen 0.0.0.0
    NAMES     SIZE
    status2   12.3kB (virtual 45.4MB)
    status    4.1kB (virtual 45.4MB)
    

    The three lines from the start of the video: one by hand, two by Docker. Each container has only its small top folder; the 45 MB below is shared.

Why. A container isn't a thing in Linux. It's a process started with the parts you used: a folder, namespaces, a control group and a user. Docker doesn't do a job Linux can't do. It does the same job in one command, every time the same way, with safer defaults, like a namespace for the name and fewer powers for root, and it packs the files as an image any server can download.

Clean up

Delete Docker's containers and its volume first, then take the hand-built container apart with clean.sh, from the lab's folder:

sudo docker rm -f status status2
sudo docker volume rm status-data
./clean.sh

If you did the registry extra, remove it too, with its volume: sudo docker rm -f -v registry. Easier still, delete the whole server. On your computer:

multipass delete --purge server-1

Newsletter · Free

Get new exercises by email

Every new video comes with an exercise like this one.

Loading signup form…

Free. Unsubscribe anytime. Form not loading? Subscribe here.