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

windows: explicitly provide the network name override to nat when using bridge network mode #3564

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

rawahars
Copy link
Contributor

@rawahars rawahars commented Feb 8, 2023

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 to nat or default docker network.

When we use bridge as the network mode, then docker daemon errors out due to bridge network not present itself. Therefore, we need to do an override for Windows such that whenever bridge mode is specified in HostConfig, we would translate it to nat network.

This PR adds support for the same.

Implementation details

We already have a method named platformHostConfigOverride in task_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 and default 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.

@rawahars rawahars requested a review from a team as a code owner February 8, 2023 15:12
@rawahars rawahars requested a review from a team February 8, 2023 15:12
…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.
Copy link
Contributor

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"
Copy link
Contributor

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?

@sparrc sparrc merged commit b0d60fb into aws:dev Mar 6, 2023
@mye956 mye956 mentioned this pull request Mar 7, 2023
@ubhattacharjya ubhattacharjya mentioned this pull request Mar 13, 2023
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.

None yet

8 participants