← Back to writing

Article · python / docker-compose / volumes

ComposeVolumeCheck: are you pointing to the same volume name?

Compare the resolved volume name for a selected service and mount in two local Compose JSON files, and understand what name equality does not establish.

If an application does not show the data you expect after a deployment change, one useful detail to inspect is the volume name it points to. Using a different named volume is one possible reason an application could open with a different data set. Configuration alone can answer only a narrow part of that question: has the resolved name for the selected mount changed?

ComposeVolumeCheck is a small Python tool built around that question. It reads two local JSON files prepared by the user and compares the named volume for one service and one container mount target. It does not connect to a server, invoke Docker, or modify configuration.

Capture the intended contexts first

Docker documents that docker compose config merges Compose files, resolves variables, and expands short notation into canonical form. Its --format json option produces a JSON model. Prepare the two inputs separately in the intended before and after contexts. Docker Compose config documentation

That context includes the Compose files, project selection, and relevant environment values. Generating two outputs from the same context does not by itself capture a change. The tool cannot verify that Compose produced the files or that they represent the intended environments; preparing those inputs is the user's responsibility.

From a model label to a resolved name

For the selected mount, the tool follows its source value to the top-level volumes entry and compares the explicit name field there. Docker states that this name is used as supplied and is not scoped by the project name. Looking only at a logical volume label or project name is therefore insufficient. Docker Compose volumes documentation

In a synthetic example, the project name can change while the explicit volume name remains fixed. In another, the logical source label can change while both entries resolve to the same name. Both produce a name-equality result. If the resolved names differ, the tool flags a different volume name for the same service and target. It does not invent a missing name by joining a project name and a label.

Three outcomes for one comparison

Exit code 0 means the supported records have equal resolved names; 1 means the names differ; 2 means a decision could not be made or the input could not be processed. JSON mode also uses fixed Turkish keys. Output does not include file paths, service or target arguments, or volume names.

The supported scope is deliberately small. Bind and anonymous mounts, external volumes, custom drivers, non-empty driver options, and volume subpaths do not receive a comparison result. Ambiguous, duplicate, or non-canonical target records also prevent a reliable decision. See the GitHub README, in Turkish, for the full input limits and commands.

What does an equal name establish?

Equal names do not establish that both configurations reach the same Docker host or physical storage. They do not establish that data exists, that it is consistent, that a backup can be restored, or that an update is safe. A different-name result is also insufficient to diagnose data loss; it is a configuration detail to investigate.

Use the tool as a small check within an existing backup and change-review process. Config JSON may contain sensitive values resolved from the environment, so keep these files private and use synthetic inputs when sharing examples.

Technical references and the tool's comparison limits are collected in the GitHub README.

← Back to writingmuhammet.saridogan.work@gmail.com