liveBook · Manning

Virtual filesystem

As explained in Learn Docker in a Month of Lunches, Second Edition

A virtual filesystem is a software-provided representation of files and directories exposed to a running container.

A virtual filesystem gives each running container its own software-provided disk view. Docker builds that view by merging image layers, then allows the container to change its own files without changing the image or other containers. section 6.1

Compare two containers

Run two containers from the same image. Each writes to /random/number.txt, but the files contain different random values. Copy both files to the host with docker container cp and compare them. The containers retain their files after exiting, while deleting a container removes that transient state. section 6.1

docker container run --name rn1 diamol/ch06-random-number:2e
docker container run --name rn2 diamol/ch06-random-number:2e

Use the supplied commands to start two containers from the same image and observe independent filesystem contents. section 6.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains merged image layers, per-container isolation, writable state, and inspection commands, but stops short of persistent volume implementation.
Examples
Demonstrates two random-number containers and copies their same-path files to the host for comparison.
What it assumes
Assumes basic familiarity with Docker images and containers, then demonstrates filesystem isolation through commands.
What you can do after
Operate Docker containers and inspect their isolated files with docker container cp.
How it connects
Connects virtual filesystems with Docker images, containers, image layers, container state, and Docker volumes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.