Skip to content

Commit

Permalink
backport of commit fe9bd3f (#15741)
Browse files Browse the repository at this point in the history
This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core authored Jan 10, 2023
1 parent b896b98 commit ed73657
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/15732.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
docker: configure restart policy for bridge network pause container
```
6 changes: 6 additions & 0 deletions drivers/docker/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ func (d *Driver) createSandboxContainerConfig(allocID string, createSpec *driver
// Set the network mode to none which creates a network namespace
// with only a loopback interface.
NetworkMode: "none",

// Set the restart policy to unless-stopped. The pause container should
// never not be running until Nomad issues a stop.
//
// https://docs.docker.com/engine/reference/run/#restart-policies---restart
RestartPolicy: docker.RestartUnlessStopped(),
},
}, nil
}
6 changes: 4 additions & 2 deletions drivers/docker/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func TestDriver_createSandboxContainerConfig(t *testing.T) {
Image: "gcr.io/google_containers/pause-amd64:3.1",
},
HostConfig: &docker.HostConfig{
NetworkMode: "none",
NetworkMode: "none",
RestartPolicy: docker.RestartUnlessStopped(),
},
},
name: "no input hostname",
Expand All @@ -45,7 +46,8 @@ func TestDriver_createSandboxContainerConfig(t *testing.T) {
Hostname: "linux",
},
HostConfig: &docker.HostConfig{
NetworkMode: "none",
NetworkMode: "none",
RestartPolicy: docker.RestartUnlessStopped(),
},
},
name: "supplied input hostname",
Expand Down

0 comments on commit ed73657

Please sign in to comment.