Restore 'database' DNS alias on the postgres compose service#224
Merged
Conversation
The database service declares hostname: database-app-container, which on some Docker/Compose versions causes the embedded DNS to register *only* that hostname and drop the default service-name alias. Result: web and sidekiq containers cannot resolve "database" (the value used in backend/.env's POSTGRES_HOST), even though "database-app-container" works. Adding an explicit network alias keeps both names resolvable without changing the .env contract. Verified: getent hosts database / database-app-container both return the same IP, and bin/rails runner can SELECT 1 without POSTGRES_HOST overrides. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
The `database` service in `backend/docker-compose.yml` declares `hostname: database-app-container`. On some Docker / Compose / DNS resolver combinations, that explicit hostname is registered as the only DNS name on the network — the default service-name alias gets dropped — so `web` and `sidekiq` containers can no longer resolve `database`, the value the `.env` file (and `config/database.yml`) expects.
This adds an explicit `networks.default.aliases` entry so both `database` and `database-app-container` resolve to the same container, regardless of how the DNS layer behaves. `redis` and `elasticsearch` are unaffected — `redis` already happens to use its service name as the hostname, and `elasticsearch` has no `hostname:` line so it picks up the default alias automatically.
Test plan
🤖 Generated with Claude Code