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 network host addr for macOS #17

Merged
merged 1 commit into from
Oct 27, 2021

Conversation

saswatamcode
Copy link
Collaborator

This PR fixes the host address for NewDockerEnvironment for macOS. Due to docker networking being different on macOS, getting gateway IP from docker network inspect doesn't work, so a workaround is reaching gateway using gateway.docker.internal.

Based on discussion here.

cc @matej-g

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@@ -24,7 +25,8 @@ import (
)

const (
dockerLocalSharedDir = "/shared"
dockerLocalSharedDir = "/shared"
dockerMacOSGatewayAddr = "gateway.docker.internal"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be gateway.docker.internal or host.docker.internal? Trying to follow https://docs.docker.com/desktop/mac/networking/#use-cases-and-workarounds and make sense of which is which 🤔.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was also a bit confused about this. I went with gateway as NewDockerEnvironment creates a bridge network, in which case host IP wouldn't be viable.

Also, looks like Windows has identical issues as mac: https://docs.docker.com/desktop/windows/networking/

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarifying, I think both might work even on user created bridged network, so in the end it should not make any difference for our use case here.

Copy link
Collaborator

@matej-g matej-g left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! cc @bwplotka when you have a minute, please take a look / merge.

Copy link
Contributor

@squat squat left a comment

Choose a reason for hiding this comment

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

I have no say, but this LGTM :)

Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

💪🏽 Thanks!

@bwplotka bwplotka merged commit 67d5389 into efficientgo:main Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants