Repository navigation
fix(docker): pin the compose project name - #9
Merged
Merged
Conversation
Compose derives the project name from the directory holding the file, which here is `docker` — a name any number of repositories will produce. Two of them on one machine share a project, and `up -d` in either one recreates the other's containers under the same service name; `down` removes them. This is not hypothetical. It destroyed a running WebDAV gateway belonging to a different repository on this machine, and the recreate scrolled past looking like normal startup output for the container that was being started. With the name pinned the collision surfaces as a port bind failure instead — loud, and harmless to whatever is already there. docker/README.md explains the trade and points at DAV_BIND_PORT for running alongside another server. The compat stack gets a name too. It runs `down --remove-orphans`, so misidentifying its project is the more destructive of the two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
何が起きるか
compose のプロジェクト名は、既定では compose ファイルのあるディレクトリ名 から決まる。ここでは
dockerになる。docker/の下に compose を置くリポジトリはいくらでもあるので、そういうものが 1 台のマシンに 2 つあると同じプロジェクトと見なされる。片方でup -dを叩くと、同一サービス名のもう片方のコンテナが recreate される。downなら消える。仮の話ではない。 このマシン上で、別リポジトリが動かしていた本番の WebDAV ゲートウェイをこれで破壊した。しかも
up -dの出力に出るContainer <相手の名前> Recreatedは、これから起動する自分のコンテナのログに紛れて読み飛ばしやすい。直したあとの挙動
プロジェクト名を固定すると、衝突はポートの bind 失敗として出る:
うるさいが、相手には触らない。これが正しい失敗の仕方。
確認
本番コンテナを動かしたまま、こちらで
up -dを叩いて検証した:並走させたい場合のポート変更も実際に確かめた (
DAV_BIND_PORT=8090でlive.mjs66/66 通過、その間 8080 の本番は 207 のまま)。手順はdocker/README.mdに書いた。compat 側にも入れた
docker/compat/compose.ymlはdown --remove-orphansを掛けるので、プロジェクトを取り違えたときの破壊力はこちらのほうが大きい。🤖 Generated with Claude Code