-
Notifications
You must be signed in to change notification settings - Fork 618
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
windows: explicitly provide the network name override to nat when using bridge network mode #3564
Conversation
…ng bridge mode On Linux, the default network mode is bridge wherein all the containers are attached to a common docker bridge network. On Windows, this default mode translates to "nat" or "default" network. When we use "bridge" as the network mode, then docker daemon error out due to "bridge" network not present itself. Therefore, we need to do an override for Windows such that whenever "bridge" mode is specified, we would translate it to "nat" network. This commit adds support for the same.
@@ -105,6 +109,13 @@ func (task *Task) platformHostConfigOverride(hostConfig *dockercontainer.HostCon | |||
hostConfig.MemoryReservation = 0 | |||
} | |||
|
|||
// On Windows, bridge mode equivalent for Linux is "default" or "nat" network. | |||
// We need to perform explicit conversion for the same. |
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.
A mental note on the comment above and how to think about these concepts:
The "bridge" networkMode here is ECS' network mode, not docker's. The fact that docker also has a networking mode called "bridge" should be treated as coincidental. Today ECS' bridge is implemented with docker's bridge under the hood, but that can change in the future.
Therefore, instead of saying "bridge mode equivalent is 'nat'", we should say "On Windows, ECS' bridge mode is implemented with "nat" mode."
|
||
// windowsDefaultNetworkName is the name of the docker network to which the containers in | ||
// default mode are attached to. | ||
windowsDefaultNetworkName = "nat" |
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.
Minor: Do you need to prefix the variable with "windows" here, since this file is already Windows-specific?
Summary
On Linux, the default network mode is
bridge
wherein all the containers are attached to a common docker bridge network. On Windows, this default mode translates tonat
ordefault
docker network.When we use
bridge
as the network mode, then docker daemon errors out due tobridge
network not present itself. Therefore, we need to do an override for Windows such that wheneverbridge
mode is specified in HostConfig, we would translate it tonat
network.This PR adds support for the same.
Implementation details
We already have a method named
platformHostConfigOverride
intask_windows.go
which performs platform specific overrides in the HostConfig. We have added the translation logic in the same method.Testing
A custom binary of the agent was built and was tested out.
Ran a bunch of tasks with both
bridge
anddefault
mode.New tests cover the changes: Yes
Description for the changelog
windows: explicitly provide the network name override to nat when using bridge network mode
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.