Skip to content
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: docker containers don't listen to host.docker.internal #614

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testhelper/docker/resource/internal/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/ory/dockertest/v3/docker"
)

const BindHostIP = "127.0.0.1"
const BindHostIP = "0.0.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.0.0.0 would be corresponding to all the interfaces(including IPV6), we can introduce a new ip for 172.17.0.1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host.docker.internal doesn't always resolve to the same ip...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of Docker Desktop for Mac, this causes issues :(

API error (500): driver failed programming external connectivity on endpoint thirsty_napier (78e1f6fa6a0132e1f00cbadbb20ef86b89d7cdc55ddd6828c0eb7bbc9516d67a): failed to bind port 127.0.0.1:55053/tcp: listen tcp4 127.0.0.1:55053: bind: address already in use

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihir20 the only way I can think right now is in #616


// IPv4PortBindings returns the port bindings for the given exposed ports forcing ipv4 address.
func IPv4PortBindings(exposedPorts []string) map[docker.Port][]docker.PortBinding {
Expand Down
Loading