|
| 1 | +--- |
| 2 | +summary: Accept the service `container_name` key, resolving it to 127.0.0.1 like `hostname` and network aliases. |
| 3 | +--- |
| 4 | + |
| 5 | +# Change: Support the service `container_name` key |
| 6 | + |
| 7 | +**Lane:** lightweight — two files (`parsing.py`, `graph.py`), no new file, no |
| 8 | +public-API change, mirrors the already-shipped `hostname` support exactly. |
| 9 | + |
| 10 | +## Goal |
| 11 | + |
| 12 | +`validate()` rejects the service `container_name` key |
| 13 | +(`service 'application': unsupported key 'container_name'`). A real compose |
| 14 | +file sets `container_name: calutron-ronline` and other services (or the host |
| 15 | +tooling) reach it by that name — the reporting user confirmed it is "also used |
| 16 | +as hostname." Fix: accept `container_name` and make it resolvable to loopback, |
| 17 | +the same treatment `hostname` already gets. |
| 18 | + |
| 19 | +## Approach |
| 20 | + |
| 21 | +Same shape as the `hostname` change |
| 22 | +(`planning/changes/2026-07-08.01-service-hostname.md`): |
| 23 | + |
| 24 | +- `parsing.py`: add `"container_name"` to `SUPPORTED_SERVICE_KEYS`. |
| 25 | +- `graph.py`: `hostnames()` also collects `svc.get("container_name")` |
| 26 | + (truthy-guarded, same pattern as `hostname`), so it becomes an |
| 27 | + `--add-host <container_name>:127.0.0.1` entry. |
| 28 | + |
| 29 | +Explicitly **not** changed: `emit.run_flags` keeps naming the actual podman |
| 30 | +container `{pod}-{name}` (`emit.py:47`) — that internal name is what |
| 31 | +`podman cp`, the healthcheck `wait_healthy` calls, and the target-container |
| 32 | +inspect/log calls all reference. Renaming the real `--name` to the compose |
| 33 | +`container_name` would require rewiring every one of those references for no |
| 34 | +resolution benefit: the pod's shared UTS/network namespace means only name |
| 35 | +*resolution* is meaningful to other services, not the literal running |
| 36 | +container's identity, which `--add-host` already supplies. |
| 37 | + |
| 38 | +## Non-goals |
| 39 | + |
| 40 | +- No `podman run --name <container_name>` — see rationale above. |
| 41 | +- No uniqueness/collision validation between `container_name`, `hostname`, and |
| 42 | + service names — `hostnames()` already tolerates duplicate entries (harmless |
| 43 | + repeated `--add-host` of the same loopback mapping), consistent with the |
| 44 | + `hostname` change's accepted risk. |
| 45 | + |
| 46 | +## Testing |
| 47 | + |
| 48 | +TDD, `just test-ci` at 100% line coverage. |
| 49 | + |
| 50 | +- Unit (`test_parsing.py`): a service with `container_name` validates without raising. |
| 51 | +- Unit (`test_graph.py`): `hostnames()` includes a service's `container_name`. |
| 52 | +- Integration (`test_emit.py`): `container_name` round-trips through |
| 53 | + `validate` → `emit_script` and the rendered script contains |
| 54 | + `--add-host <name>:127.0.0.1`. |
| 55 | + |
| 56 | +## Risk |
| 57 | + |
| 58 | +Low — identical mechanism to the already-shipped, tested `hostname` support. |
0 commit comments