-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix postgres-dev to only listen on localhost #3403
Conversation
I missed the |
4d61085
to
d1c06eb
Compare
postgres:14-alpine -c fsync=off -c full_page_writes=off | ||
-p 127.0.0.1:15432:5432 \ | ||
postgres:14-alpine -c fsync=off -c full_page_writes=off \ | ||
-c listen_addresses=127.0.0.1 -c max_connections=100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the default settings, but I'd like to include them here to make it easier to change them.
On linux setting listen_addresses
to 0.0.0.0
allows tests to bypass the port mapping proxy and connect directly to the container. Setting max_connections
can be useful when testing concurrency.
d1c06eb
to
a8925de
Compare
@@ -48,7 +48,7 @@ jobs: | |||
--health-interval 10s | |||
--health-timeout 5s | |||
--health-retries 5 | |||
ports: ["5432:5432"] | |||
ports: ["127.0.0.1:5432:5432"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this will work, let's see if CI tests pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed this works on Docker Desktop for Mac
Thanks! |
Summary
The default for docker port mapping is
0.0.0.0
(all interfaces), which can be a security risk. If a developer laptop is ever connected to an untrusted network, someone on that network could connect to the database and useCOPY
and other postgres operations to read files or even run processes on the laptop.By mapping the host port to 127.0.0.1 we ensure that no one can connect to the dev database except for the processes on the local host.
If you are using Docker for Mac I could use your help to confirm this works with that setup.