Separate Container Metadata from Task Lifetime · containerd
A container object can exist without a running process.
Learn with progress and quizzesFirst, understand the concepts.
Container object
The object holds image, command, and runtime configuration. containers create alone does not start the process.
Task
A task represents execution state. Create metadata first, then start the task and inspect its PID and status separately.
Cleanup order
Stop and remove only this practice task, then remove its container and image. Do not stop tasks in other namespaces.
Why it matters
A containerd Container is execution metadata; a Task represents process execution. Separate lists explain why a container object can exist without a running process.
Work through the reasoning
Observe creation before startup
After containers create, settings exist without a task. Verify a PID and RUNNING after tasks start before claiming process execution.
Separate stopping and deletion
Stopping the process, deleting the stopped task, and deleting metadata are distinct steps. Cleanup proceeds from the task to container references, then the image and namespace.
Learn by doing.
Use a personal Linux practice VM with containerd, runc, ctr, and sudo access. The nerdctl lab also needs nerdctl; the CRI lab needs crictl and a practice node with CRI enabled. Examples assume /run/containerd/containerd.sock; check the actual socket in other environments.
Create a BusyBox sleep container in a separate namespace and compare lists before and after starting its task. Cleanup targets only this task.
sudo ctr namespaces create study-ctr-tasks
sudo ctr --namespace study-ctr-tasks images pull docker.io/library/busybox:1.36
sudo ctr --namespace study-ctr-tasks containers create docker.io/library/busybox:1.36 study-sleeper /bin/sleep 3600
sudo ctr --namespace study-ctr-tasks containers ls
sudo ctr --namespace study-ctr-tasks tasks ls
sudo ctr --namespace study-ctr-tasks tasks start --detach study-sleeper < /dev/null
sudo ctr --namespace study-ctr-tasks tasks ls
sudo ctr --namespace study-ctr-tasks tasks exec --exec-id study-check study-sleeper /bin/echo task-alive < /dev/nullHow to check your result
Before startup, containers ls should list the object while tasks ls shows no execution. After startup, look for a PID and RUNNING, then task-alive from exec. ctr is diagnostic, so check your version’s --help as needed.
Clean up practice resources
Run after checking the result. Confirm these resources belong to your practice run and contain no data you need to keep.
sudo ctr --namespace study-ctr-tasks tasks kill --signal SIGKILL study-sleeper
sudo ctr --namespace study-ctr-tasks tasks delete study-sleeper
sudo ctr --namespace study-ctr-tasks containers delete study-sleeper
sudo ctr --namespace study-ctr-tasks images rm --sync docker.io/library/busybox:1.36
sudo ctr namespaces remove study-ctr-tasksApply what you learned
A Container exists but the task list is empty. Can you conclude that its image is corrupt?
Reveal the reasoning after trying
It may never have been started, or its task may have been removed. Check lifecycle history and namespace first. Image corruption needs additional evidence such as execution errors.
Ready to check your understanding?
Which object represents an executing process and its state?
- An image tag
- A namespace string
- A Task
- A Dockerfile
Reveal the reasoning after trying
A Task
A Container holds metadata, while a Task represents execution. Metadata creation and process startup can be observed separately.
Official documentation · Separate Container Metadata from Task Lifetime