liveBook · Manning

Container filesystem

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

A container filesystem is the filesystem associated with a container and persisted as part of its container state.

A container filesystem is the virtual disk visible inside a container. Docker builds it from image layers and one writable layer, so applications work with ordinary files and directories. Changes made in the writable layer affect only that container; they do not modify the image or other containers. section 6.1 section 6.5

Choose the storage source according to how long the data must live:

  • Use the writable layer for transient data such as a local cache. Removing the container removes this layer and its data. section 6.1 section 6.5
  • Use Docker volumes or mounts when data must survive container replacement; these sources have a separate lifecycle from containers. section 6.1
  • Use local bind mounts to share host files with a container, including source code that should update immediately after local edits. section 6.5
  • Treat distributed bind mounts as slower and potentially less feature-complete than local disk; use them for configuration, shared caches, or data storage. section 6.5

See container data disappear

Create a container, copy a file into its filesystem, and run it again to observe the modified state. Start another container from the same image: it sees the original image content. Remove the first container, and its changed file is gone with the writable layer.

Figure 6.15 The container filesystem is created from the union of multiple sources.
figure

Inspect how image layers, mounts, and the writable layer are combined into the single filesystem visible inside a container. section 6.5

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

How deep it goes
Explains layered construction and lifecycle consequences, but defers union-filesystem implementation because it varies across operating systems.
Examples
Demonstrates file copying, container restart, replacement containers, exited containers, and a web server running in the background.
What it assumes
Assumes basic Docker commands for running, starting, copying files between, listing, and removing containers.
What you can do after
Operate/configure container storage by choosing transient layers, volumes, or mounts according to data lifetime and sharing needs.
How it connects
Connects container filesystems with image layers, writable layers, Docker volumes, bind mounts, and union filesystems.

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.