fix(docker): bind postgres to localhost only#686
fix(docker): bind postgres to localhost only#686nick-stebbings wants to merge 1 commit intonearai:mainfrom
Conversation
5432:5432 → 127.0.0.1:5432:5432 — the default docker-compose.yml exposed postgres on all interfaces, making it reachable from the local network in any docker compose deployment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the default security configuration of the Docker Compose setup by ensuring the PostgreSQL database is only accessible from the host machine. This change prevents unintended network exposure of the database to other machines on the local network, thereby improving the security posture of the development environment by default. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly enhances security by binding the PostgreSQL service in the Docker Compose setup to localhost. This prevents unintended exposure on local networks. My review includes one suggestion to further improve the configuration's flexibility for developers by making the host port configurable, which can help avoid common port conflicts in local environments.
| image: pgvector/pgvector:pg16 | ||
| ports: | ||
| - "5432:5432" | ||
| - "127.0.0.1:5432:5432" |
There was a problem hiding this comment.
To improve flexibility for local development, consider making the host port configurable using an environment variable. This will prevent potential port conflicts if a developer already has a service running on port 5432. Using a variable with a default value allows for easy overrides without breaking the default setup.
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
Summary
The default
docker-compose.ymlexposes postgres on all interfaces (0.0.0.0:5432), making it reachable from the local network in any docker compose deployment. This binds it to127.0.0.1:5432:5432so it's only accessible from the host machine.Test plan
docker compose upstill workspsql -h 127.0.0.1 -U ironclaw -d ironclawconnects🤖 Generated with Claude Code