CertGrid CertGrid
Hands-on Lab·CompTIA Linux+

A Containerfile, an image, and what it runs as

Containers appear in 46 questions of the XK0-006 pool and Kubernetes in 4, so Domain 4's container content is images and how you run them. This guide writes a Containerfile, builds it, reads the layers it produced with their sizes, runs it twice to separate ENTRYPOINT from CMD, and generates a systemd unit for it without installing anything.

Automation and Scripting Guide 14 of 28 Intermediate

One host, rootless throughout. The image is built, run, inspected and deleted by an ordinary user with no root anywhere on the page.
Server NameIP AddressOSRolesCPURAMHDD
LPLUS-A01192.168.0.73Ubuntu 26.04 LTSDebian-family host - apt, ufw, netplan, AppArmor2 Core4 GB50 GB

This guide includes

Use this when packaging a script or a tool so it runs the same way everywhere. This matters because the two instructions that decide what a container runs - ENTRYPOINT and CMD - are routinely confused, and the difference decides whether an argument you pass replaces the command or is given to it.

Before you start

  1. A Containerfile, and what each instruction is for

  2. Building it, and what the build produced

  3. Running it, and the two ways to pass an argument

  4. What the image actually is

  5. A unit file for it, generated rather than written

  6. Putting the machine back

Official sources