Challenge
DifficultyMedium
Community stats483 solved of 964 attempts

Extract the Filesystem of a Container Image

Can you unpack the filesystem of a container image into a local directory?

Premium Challenge

Upgrade your membership to unlock this and all other premium materials.

Upgrade

Internally, container images have a layered structure, with each layer representing a filesystem diff produced by a corresponding RUN, COPY, or ADD instruction in its Dockerfile. However, when a container is created from an image, its filesystem appears as a standard Linux directory structure. Usually, it's a responsibility of the runtime to mount the image layers as a container filesystem, but sometimes, a need to manually extract the packaged filesystem into a local folder may arise. In particular, this may be useful for debugging purposes.

Layered container images vs. traditional filesystems.

In this challenge, you will need to unpack the filesystem of a container image into a local directory. The image is already pulled for you - you can find it in the output of the docker images command. Store its filesystem in the ~/imagefs directory. Make sure you export the filesystem of this exact image variant (platform linux/s390x), because it may differ from the filesystem of the same image on other platforms.

Hint 1

Don't use the docker save command - it dumps the "raw" layered structure of the image, while you need to extract the "baked" filesystem of the image.

Hint 2

The crane export command also writes the merged filesystem of an image as a tar stream. Keep in mind that crane pulls the image from the registry by itself and exports the linux/amd64 variant unless you pass the --platform flag.

Hint 3

Feeling a bit lost? Check out this short tutorial - How To Extract Container Image Filesystem Using Docker.