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

Set windows containers default network mode to 'nat' #1521

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task,
hostConfig.NetworkMode = driverConfig.NetworkMode
if hostConfig.NetworkMode == "" {
// docker default
d.logger.Println("[DEBUG] driver.docker: networking mode not specified; defaulting to bridge")
hostConfig.NetworkMode = "bridge"
d.logger.Printf("[DEBUG] driver.docker: networking mode not specified; defaulting to %s", defaultNetworkMode)
hostConfig.NetworkMode = defaultNetworkMode
}

// Setup port mapping and exposed ports
Expand Down
5 changes: 5 additions & 0 deletions client/driver/docker_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ package driver

import docker "github.com/fsouza/go-dockerclient"

const (
//Setting default network mode for non-windows OS as bridge
defaultNetworkMode = "bridge"
)

func getPortBinding(ip string, port string) []docker.PortBinding {
return []docker.PortBinding{docker.PortBinding{HostIP: ip, HostPort: port}}
}
5 changes: 5 additions & 0 deletions client/driver/docker_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package driver

import docker "github.com/fsouza/go-dockerclient"

const (
//Default network mode for windows containers is nat
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future please put a space after the //

defaultNetworkMode = "nat"
)

//Currently Windows containers don't support host ip in port binding.
func getPortBinding(ip string, port string) []docker.PortBinding {
return []docker.PortBinding{docker.PortBinding{HostIP: "", HostPort: port}}
Expand Down