Follow-up to 494677f93f04ab3ad4c295c0e92ac05bfe0a546a, which added
the aliases, but did not yet replace our own use of the nat types.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -23,6 +23,7 @@ import ( |
| 23 | 23 |
"github.com/moby/buildkit/frontend/dockerfile/instructions" |
| 24 | 24 |
"github.com/moby/buildkit/frontend/dockerfile/parser" |
| 25 | 25 |
"github.com/moby/buildkit/frontend/dockerfile/shell" |
| 26 |
+ "github.com/moby/moby/api/types/container" |
|
| 26 | 27 |
"github.com/moby/moby/api/types/jsonstream" |
| 27 | 28 |
"github.com/moby/sys/signal" |
| 28 | 29 |
ocispec "github.com/opencontainers/image-spec/specs-go/v1" |
| ... | ... |
@@ -530,7 +531,7 @@ func dispatchExpose(ctx context.Context, d dispatchRequest, c *instructions.Expo |
| 530 | 530 |
} |
| 531 | 531 |
|
| 532 | 532 |
if d.state.runConfig.ExposedPorts == nil {
|
| 533 |
- d.state.runConfig.ExposedPorts = make(nat.PortSet) |
|
| 533 |
+ d.state.runConfig.ExposedPorts = make(container.PortSet) |
|
| 534 | 534 |
} |
| 535 | 535 |
for p := range ps {
|
| 536 | 536 |
d.state.runConfig.ExposedPorts[p] = struct{}{}
|
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/daemon/internal/image" |
| 13 | 13 |
"github.com/docker/docker/daemon/pkg/oci" |
| 14 | 14 |
"github.com/docker/docker/daemon/server/backend" |
| 15 |
- "github.com/docker/go-connections/nat" |
|
| 16 | 15 |
"github.com/moby/buildkit/frontend/dockerfile/instructions" |
| 17 | 16 |
"github.com/moby/buildkit/frontend/dockerfile/parser" |
| 18 | 17 |
"github.com/moby/buildkit/frontend/dockerfile/shell" |
| ... | ... |
@@ -337,9 +336,7 @@ func TestExpose(t *testing.T) {
|
| 337 | 337 |
assert.Assert(t, sb.state.runConfig.ExposedPorts != nil) |
| 338 | 338 |
assert.Assert(t, is.Len(sb.state.runConfig.ExposedPorts, 1)) |
| 339 | 339 |
|
| 340 |
- portsMapping, err := nat.ParsePortSpec(exposedPort) |
|
| 341 |
- assert.NilError(t, err) |
|
| 342 |
- assert.Check(t, is.Contains(sb.state.runConfig.ExposedPorts, portsMapping[0].Port)) |
|
| 340 |
+ assert.Check(t, is.Contains(sb.state.runConfig.ExposedPorts, container.PortRangeProto("80/tcp")))
|
|
| 343 | 341 |
} |
| 344 | 342 |
|
| 345 | 343 |
func TestUser(t *testing.T) {
|
| ... | ... |
@@ -17,7 +17,6 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/daemon/internal/stringid" |
| 18 | 18 |
networkSettings "github.com/docker/docker/daemon/network" |
| 19 | 19 |
"github.com/docker/docker/daemon/server/backend" |
| 20 |
- "github.com/docker/go-connections/nat" |
|
| 21 | 20 |
"github.com/moby/go-archive" |
| 22 | 21 |
"github.com/moby/go-archive/chrootarchive" |
| 23 | 22 |
"github.com/moby/moby/api/types/build" |
| ... | ... |
@@ -294,7 +293,7 @@ func copyRunConfig(runConfig *container.Config, modifiers ...runConfigModifier) |
| 294 | 294 |
} |
| 295 | 295 |
|
| 296 | 296 |
if cfgCopy.ExposedPorts != nil {
|
| 297 |
- cfgCopy.ExposedPorts = make(nat.PortSet, len(runConfig.ExposedPorts)) |
|
| 297 |
+ cfgCopy.ExposedPorts = make(container.PortSet, len(runConfig.ExposedPorts)) |
|
| 298 | 298 |
for k, v := range runConfig.ExposedPorts {
|
| 299 | 299 |
cfgCopy.ExposedPorts[k] = v |
| 300 | 300 |
} |
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/daemon/internal/image" |
| 13 | 13 |
"github.com/docker/docker/daemon/internal/layer" |
| 14 | 14 |
"github.com/docker/docker/daemon/server/backend" |
| 15 |
- "github.com/docker/go-connections/nat" |
|
| 16 | 15 |
"github.com/moby/go-archive" |
| 17 | 16 |
"github.com/moby/moby/api/types/build" |
| 18 | 17 |
"github.com/moby/moby/api/types/container" |
| ... | ... |
@@ -138,7 +137,7 @@ func fullMutableRunConfig() *container.Config {
|
| 138 | 138 |
return &container.Config{
|
| 139 | 139 |
Cmd: []string{"command", "arg1"},
|
| 140 | 140 |
Env: []string{"env1=foo", "env2=bar"},
|
| 141 |
- ExposedPorts: nat.PortSet{
|
|
| 141 |
+ ExposedPorts: container.PortSet{
|
|
| 142 | 142 |
"1000/tcp": {},
|
| 143 | 143 |
"1001/tcp": {},
|
| 144 | 144 |
}, |
| ... | ... |
@@ -14,9 +14,8 @@ import ( |
| 14 | 14 |
executorpkg "github.com/docker/docker/daemon/cluster/executor" |
| 15 | 15 |
clustertypes "github.com/docker/docker/daemon/cluster/provider" |
| 16 | 16 |
"github.com/docker/docker/daemon/libnetwork/scope" |
| 17 |
- "github.com/docker/go-connections/nat" |
|
| 18 | 17 |
gogotypes "github.com/gogo/protobuf/types" |
| 19 |
- containertypes "github.com/moby/moby/api/types/container" |
|
| 18 |
+ "github.com/moby/moby/api/types/container" |
|
| 20 | 19 |
"github.com/moby/moby/api/types/events" |
| 21 | 20 |
"github.com/moby/moby/api/types/filters" |
| 22 | 21 |
enginemount "github.com/moby/moby/api/types/mount" |
| ... | ... |
@@ -52,13 +51,13 @@ func (c *containerConfig) setTask(t *api.Task, node *api.NodeDescription) error |
| 52 | 52 |
return exec.ErrRuntimeUnsupported |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
- container := t.Spec.GetContainer() |
|
| 56 |
- if container != nil {
|
|
| 57 |
- if container.Image == "" {
|
|
| 55 |
+ ctr := t.Spec.GetContainer() |
|
| 56 |
+ if ctr != nil {
|
|
| 57 |
+ if ctr.Image == "" {
|
|
| 58 | 58 |
return ErrImageRequired |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
- if err := validateMounts(container.Mounts); err != nil {
|
|
| 61 |
+ if err := validateMounts(ctr.Mounts); err != nil {
|
|
| 62 | 62 |
return err |
| 63 | 63 |
} |
| 64 | 64 |
} |
| ... | ... |
@@ -140,8 +139,8 @@ func (c *containerConfig) image() string {
|
| 140 | 140 |
return reference.FamiliarString(reference.TagNameOnly(ref)) |
| 141 | 141 |
} |
| 142 | 142 |
|
| 143 |
-func (c *containerConfig) portBindings() nat.PortMap {
|
|
| 144 |
- portBindings := nat.PortMap{}
|
|
| 143 |
+func (c *containerConfig) portBindings() container.PortMap {
|
|
| 144 |
+ portBindings := container.PortMap{}
|
|
| 145 | 145 |
if c.task.Endpoint == nil {
|
| 146 | 146 |
return portBindings |
| 147 | 147 |
} |
| ... | ... |
@@ -151,8 +150,8 @@ func (c *containerConfig) portBindings() nat.PortMap {
|
| 151 | 151 |
continue |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 |
- port := nat.Port(fmt.Sprintf("%d/%s", portConfig.TargetPort, strings.ToLower(portConfig.Protocol.String())))
|
|
| 155 |
- binding := []nat.PortBinding{
|
|
| 154 |
+ port := container.PortRangeProto(fmt.Sprintf("%d/%s", portConfig.TargetPort, strings.ToLower(portConfig.Protocol.String())))
|
|
| 155 |
+ binding := []container.PortBinding{
|
|
| 156 | 156 |
{},
|
| 157 | 157 |
} |
| 158 | 158 |
|
| ... | ... |
@@ -165,7 +164,7 @@ func (c *containerConfig) portBindings() nat.PortMap {
|
| 165 | 165 |
return portBindings |
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 |
-func (c *containerConfig) isolation() containertypes.Isolation {
|
|
| 168 |
+func (c *containerConfig) isolation() container.Isolation {
|
|
| 169 | 169 |
return convert.IsolationFromGRPC(c.spec().Isolation) |
| 170 | 170 |
} |
| 171 | 171 |
|
| ... | ... |
@@ -177,8 +176,8 @@ func (c *containerConfig) init() *bool {
|
| 177 | 177 |
return &init |
| 178 | 178 |
} |
| 179 | 179 |
|
| 180 |
-func (c *containerConfig) exposedPorts() map[nat.Port]struct{} {
|
|
| 181 |
- exposedPorts := make(map[nat.Port]struct{})
|
|
| 180 |
+func (c *containerConfig) exposedPorts() map[container.PortRangeProto]struct{} {
|
|
| 181 |
+ exposedPorts := make(map[container.PortRangeProto]struct{})
|
|
| 182 | 182 |
if c.task.Endpoint == nil {
|
| 183 | 183 |
return exposedPorts |
| 184 | 184 |
} |
| ... | ... |
@@ -188,18 +187,18 @@ func (c *containerConfig) exposedPorts() map[nat.Port]struct{} {
|
| 188 | 188 |
continue |
| 189 | 189 |
} |
| 190 | 190 |
|
| 191 |
- port := nat.Port(fmt.Sprintf("%d/%s", portConfig.TargetPort, strings.ToLower(portConfig.Protocol.String())))
|
|
| 191 |
+ port := container.PortRangeProto(fmt.Sprintf("%d/%s", portConfig.TargetPort, strings.ToLower(portConfig.Protocol.String())))
|
|
| 192 | 192 |
exposedPorts[port] = struct{}{}
|
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 | 195 |
return exposedPorts |
| 196 | 196 |
} |
| 197 | 197 |
|
| 198 |
-func (c *containerConfig) config() *containertypes.Config {
|
|
| 198 |
+func (c *containerConfig) config() *container.Config {
|
|
| 199 | 199 |
genericEnvs := genericresource.EnvFormat(c.task.AssignedGenericResources, "DOCKER_RESOURCE") |
| 200 | 200 |
env := append(c.spec().Env, genericEnvs...) |
| 201 | 201 |
|
| 202 |
- config := &containertypes.Config{
|
|
| 202 |
+ config := &container.Config{
|
|
| 203 | 203 |
Labels: c.labels(), |
| 204 | 204 |
StopSignal: c.spec().StopSignal, |
| 205 | 205 |
Tty: c.spec().TTY, |
| ... | ... |
@@ -380,7 +379,7 @@ func convertMount(m api.Mount) enginemount.Mount {
|
| 380 | 380 |
return mount |
| 381 | 381 |
} |
| 382 | 382 |
|
| 383 |
-func (c *containerConfig) healthcheck() *containertypes.HealthConfig {
|
|
| 383 |
+func (c *containerConfig) healthcheck() *container.HealthConfig {
|
|
| 384 | 384 |
hcSpec := c.spec().Healthcheck |
| 385 | 385 |
if hcSpec == nil {
|
| 386 | 386 |
return nil |
| ... | ... |
@@ -389,7 +388,7 @@ func (c *containerConfig) healthcheck() *containertypes.HealthConfig {
|
| 389 | 389 |
timeout, _ := gogotypes.DurationFromProto(hcSpec.Timeout) |
| 390 | 390 |
startPeriod, _ := gogotypes.DurationFromProto(hcSpec.StartPeriod) |
| 391 | 391 |
startInterval, _ := gogotypes.DurationFromProto(hcSpec.StartInterval) |
| 392 |
- return &containertypes.HealthConfig{
|
|
| 392 |
+ return &container.HealthConfig{
|
|
| 393 | 393 |
Test: hcSpec.Test, |
| 394 | 394 |
Interval: interval, |
| 395 | 395 |
Timeout: timeout, |
| ... | ... |
@@ -399,8 +398,8 @@ func (c *containerConfig) healthcheck() *containertypes.HealthConfig {
|
| 399 | 399 |
} |
| 400 | 400 |
} |
| 401 | 401 |
|
| 402 |
-func (c *containerConfig) hostConfig(deps exec.VolumeGetter) *containertypes.HostConfig {
|
|
| 403 |
- hc := &containertypes.HostConfig{
|
|
| 402 |
+func (c *containerConfig) hostConfig(deps exec.VolumeGetter) *container.HostConfig {
|
|
| 403 |
+ hc := &container.HostConfig{
|
|
| 404 | 404 |
Resources: c.resources(), |
| 405 | 405 |
GroupAdd: c.spec().Groups, |
| 406 | 406 |
PortBindings: c.portBindings(), |
| ... | ... |
@@ -437,7 +436,7 @@ func (c *containerConfig) hostConfig(deps exec.VolumeGetter) *containertypes.Hos |
| 437 | 437 |
} |
| 438 | 438 |
|
| 439 | 439 |
if c.task.LogDriver != nil {
|
| 440 |
- hc.LogConfig = containertypes.LogConfig{
|
|
| 440 |
+ hc.LogConfig = container.LogConfig{
|
|
| 441 | 441 |
Type: c.task.LogDriver.Name, |
| 442 | 442 |
Config: c.task.LogDriver.Options, |
| 443 | 443 |
} |
| ... | ... |
@@ -447,7 +446,7 @@ func (c *containerConfig) hostConfig(deps exec.VolumeGetter) *containertypes.Hos |
| 447 | 447 |
labels := c.task.Networks[0].Network.Spec.Annotations.Labels |
| 448 | 448 |
name := c.task.Networks[0].Network.Spec.Annotations.Name |
| 449 | 449 |
if v, ok := labels["com.docker.swarm.predefined"]; ok && v == "true" {
|
| 450 |
- hc.NetworkMode = containertypes.NetworkMode(name) |
|
| 450 |
+ hc.NetworkMode = container.NetworkMode(name) |
|
| 451 | 451 |
} |
| 452 | 452 |
} |
| 453 | 453 |
|
| ... | ... |
@@ -479,8 +478,8 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOp |
| 479 | 479 |
return nil |
| 480 | 480 |
} |
| 481 | 481 |
|
| 482 |
-func (c *containerConfig) resources() containertypes.Resources {
|
|
| 483 |
- resources := containertypes.Resources{}
|
|
| 482 |
+func (c *containerConfig) resources() container.Resources {
|
|
| 483 |
+ resources := container.Resources{}
|
|
| 484 | 484 |
|
| 485 | 485 |
// set pids limit |
| 486 | 486 |
pidsLimit := c.spec().PidsLimit |
| ... | ... |
@@ -488,9 +487,9 @@ func (c *containerConfig) resources() containertypes.Resources {
|
| 488 | 488 |
resources.PidsLimit = &pidsLimit |
| 489 | 489 |
} |
| 490 | 490 |
|
| 491 |
- resources.Ulimits = make([]*containertypes.Ulimit, len(c.spec().Ulimits)) |
|
| 491 |
+ resources.Ulimits = make([]*container.Ulimit, len(c.spec().Ulimits)) |
|
| 492 | 492 |
for i, ulimit := range c.spec().Ulimits {
|
| 493 |
- resources.Ulimits[i] = &containertypes.Ulimit{
|
|
| 493 |
+ resources.Ulimits[i] = &container.Ulimit{
|
|
| 494 | 494 |
Name: ulimit.Name, |
| 495 | 495 |
Soft: ulimit.Soft, |
| 496 | 496 |
Hard: ulimit.Hard, |
| ... | ... |
@@ -673,7 +672,7 @@ func networkCreateRequest(name string, nw *api.Network) clustertypes.NetworkCrea |
| 673 | 673 |
} |
| 674 | 674 |
} |
| 675 | 675 |
|
| 676 |
-func (c *containerConfig) applyPrivileges(hc *containertypes.HostConfig) {
|
|
| 676 |
+func (c *containerConfig) applyPrivileges(hc *container.HostConfig) {
|
|
| 677 | 677 |
privileges := c.spec().Privileges |
| 678 | 678 |
if privileges == nil {
|
| 679 | 679 |
return |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
cerrdefs "github.com/containerd/errdefs" |
| 12 | 12 |
executorpkg "github.com/docker/docker/daemon/cluster/executor" |
| 13 | 13 |
"github.com/docker/docker/daemon/libnetwork" |
| 14 |
- "github.com/docker/go-connections/nat" |
|
| 15 | 14 |
gogotypes "github.com/gogo/protobuf/types" |
| 16 | 15 |
"github.com/moby/moby/api/types/container" |
| 17 | 16 |
"github.com/moby/moby/api/types/events" |
| ... | ... |
@@ -641,7 +640,7 @@ func parsePortStatus(ctnr container.InspectResponse) (*api.PortStatus, error) {
|
| 641 | 641 |
return status, nil |
| 642 | 642 |
} |
| 643 | 643 |
|
| 644 |
-func parsePortMap(portMap nat.PortMap) ([]*api.PortConfig, error) {
|
|
| 644 |
+func parsePortMap(portMap container.PortMap) ([]*api.PortConfig, error) {
|
|
| 645 | 645 |
exposedPorts := make([]*api.PortConfig, 0, len(portMap)) |
| 646 | 646 |
|
| 647 | 647 |
for portProtocol, mapping := range portMap {
|
| ... | ... |
@@ -376,7 +376,7 @@ func validateHealthCheck(healthConfig *containertypes.HealthConfig) error {
|
| 376 | 376 |
return nil |
| 377 | 377 |
} |
| 378 | 378 |
|
| 379 |
-func validatePortBindings(ports nat.PortMap) error {
|
|
| 379 |
+func validatePortBindings(ports containertypes.PortMap) error {
|
|
| 380 | 380 |
for port := range ports {
|
| 381 | 381 |
_, portStr := nat.SplitProtoPort(string(port)) |
| 382 | 382 |
if _, err := nat.ParsePort(portStr); err != nil {
|
| ... | ... |
@@ -43,8 +43,8 @@ type Snapshot struct {
|
| 43 | 43 |
Running bool |
| 44 | 44 |
Paused bool |
| 45 | 45 |
Managed bool |
| 46 |
- ExposedPorts nat.PortSet |
|
| 47 |
- PortBindings nat.PortSet |
|
| 46 |
+ ExposedPorts container.PortSet |
|
| 47 |
+ PortBindings container.PortSet |
|
| 48 | 48 |
Health container.HealthStatus |
| 49 | 49 |
HostConfig struct {
|
| 50 | 50 |
Isolation string |
| ... | ... |
@@ -324,8 +324,8 @@ func (v *View) transform(ctr *Container) *Snapshot {
|
| 324 | 324 |
Name: ctr.Name, |
| 325 | 325 |
Pid: ctr.Pid, |
| 326 | 326 |
Managed: ctr.Managed, |
| 327 |
- ExposedPorts: make(nat.PortSet), |
|
| 328 |
- PortBindings: make(nat.PortSet), |
|
| 327 |
+ ExposedPorts: make(container.PortSet), |
|
| 328 |
+ PortBindings: make(container.PortSet), |
|
| 329 | 329 |
Health: health, |
| 330 | 330 |
Running: ctr.Running, |
| 331 | 331 |
Paused: ctr.Paused, |
| ... | ... |
@@ -395,8 +395,9 @@ func (v *View) transform(ctr *Container) *Snapshot {
|
| 395 | 395 |
} |
| 396 | 396 |
} |
| 397 | 397 |
} |
| 398 |
- for port, bindings := range ctr.NetworkSettings.Ports {
|
|
| 399 |
- p, err := nat.ParsePort(port.Port()) |
|
| 398 |
+ for p, bindings := range ctr.NetworkSettings.Ports {
|
|
| 399 |
+ proto, port := nat.SplitProtoPort(string(p)) |
|
| 400 |
+ p, err := nat.ParsePort(port) |
|
| 400 | 401 |
if err != nil {
|
| 401 | 402 |
log.G(context.TODO()).WithError(err).Warn("invalid port map")
|
| 402 | 403 |
continue |
| ... | ... |
@@ -404,7 +405,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
|
| 404 | 404 |
if len(bindings) == 0 {
|
| 405 | 405 |
snapshot.Ports = append(snapshot.Ports, container.Port{
|
| 406 | 406 |
PrivatePort: uint16(p), |
| 407 |
- Type: port.Proto(), |
|
| 407 |
+ Type: proto, |
|
| 408 | 408 |
}) |
| 409 | 409 |
continue |
| 410 | 410 |
} |
| ... | ... |
@@ -417,7 +418,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
|
| 417 | 417 |
snapshot.Ports = append(snapshot.Ports, container.Port{
|
| 418 | 418 |
PrivatePort: uint16(p), |
| 419 | 419 |
PublicPort: uint16(h), |
| 420 |
- Type: port.Proto(), |
|
| 420 |
+ Type: proto, |
|
| 421 | 421 |
IP: binding.HostIP, |
| 422 | 422 |
}) |
| 423 | 423 |
} |
| ... | ... |
@@ -101,12 +101,12 @@ func buildSandboxOptions(cfg *config.Config, ctr *container.Container) ([]libnet |
| 101 | 101 |
} |
| 102 | 102 |
} |
| 103 | 103 |
|
| 104 |
- bindings := make(nat.PortMap) |
|
| 104 |
+ bindings := make(containertypes.PortMap) |
|
| 105 | 105 |
if ctr.HostConfig.PortBindings != nil {
|
| 106 | 106 |
for p, b := range ctr.HostConfig.PortBindings {
|
| 107 |
- bindings[p] = []nat.PortBinding{}
|
|
| 107 |
+ bindings[p] = []containertypes.PortBinding{}
|
|
| 108 | 108 |
for _, bb := range b {
|
| 109 |
- bindings[p] = append(bindings[p], nat.PortBinding{
|
|
| 109 |
+ bindings[p] = append(bindings[p], containertypes.PortBinding{
|
|
| 110 | 110 |
HostIP: bb.HostIP, |
| 111 | 111 |
HostPort: bb.HostPort, |
| 112 | 112 |
}) |
| ... | ... |
@@ -115,7 +115,7 @@ func buildSandboxOptions(cfg *config.Config, ctr *container.Container) ([]libnet |
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 | 117 |
// TODO(thaJeztah): Move this code to a method on nat.PortSet. |
| 118 |
- ports := make([]nat.Port, 0, len(ctr.Config.ExposedPorts)) |
|
| 118 |
+ ports := make([]containertypes.PortRangeProto, 0, len(ctr.Config.ExposedPorts)) |
|
| 119 | 119 |
for p := range ctr.Config.ExposedPorts {
|
| 120 | 120 |
ports = append(ports, p) |
| 121 | 121 |
} |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/daemon/config" |
| 9 |
- "github.com/docker/go-connections/nat" |
|
| 10 | 9 |
containertypes "github.com/moby/moby/api/types/container" |
| 11 | 10 |
"gotest.tools/v3/assert" |
| 12 | 11 |
) |
| ... | ... |
@@ -15,12 +14,12 @@ import ( |
| 15 | 15 |
// This should not be tested on Windows because Windows doesn't support "host" network mode. |
| 16 | 16 |
func TestContainerWarningHostAndPublishPorts(t *testing.T) {
|
| 17 | 17 |
testCases := []struct {
|
| 18 |
- ports nat.PortMap |
|
| 18 |
+ ports containertypes.PortMap |
|
| 19 | 19 |
warnings []string |
| 20 | 20 |
}{
|
| 21 |
- {ports: nat.PortMap{}},
|
|
| 22 |
- {ports: nat.PortMap{
|
|
| 23 |
- "8080": []nat.PortBinding{{HostPort: "8989"}},
|
|
| 21 |
+ {ports: containertypes.PortMap{}},
|
|
| 22 |
+ {ports: containertypes.PortMap{
|
|
| 23 |
+ "8080": []containertypes.PortBinding{{HostPort: "8989"}},
|
|
| 24 | 24 |
}, warnings: []string{"Published ports are discarded when using host network mode"}},
|
| 25 | 25 |
} |
| 26 | 26 |
muteLogs(t) |
| ... | ... |
@@ -34,9 +33,9 @@ func TestContainerWarningHostAndPublishPorts(t *testing.T) {
|
| 34 | 34 |
d := &Daemon{}
|
| 35 | 35 |
cfg, err := config.New() |
| 36 | 36 |
assert.NilError(t, err) |
| 37 |
- runtimes, err := setupRuntimes(cfg) |
|
| 37 |
+ rts, err := setupRuntimes(cfg) |
|
| 38 | 38 |
assert.NilError(t, err) |
| 39 |
- daemonCfg := &configStore{Config: *cfg, Runtimes: runtimes}
|
|
| 39 |
+ daemonCfg := &configStore{Config: *cfg, Runtimes: rts}
|
|
| 40 | 40 |
wrns, err := d.verifyContainerSettings(daemonCfg, hostConfig, &containertypes.Config{}, false)
|
| 41 | 41 |
assert.NilError(t, err) |
| 42 | 42 |
assert.DeepEqual(t, tc.warnings, wrns) |
| ... | ... |
@@ -3,7 +3,6 @@ package containerd |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/go-connections/nat" |
|
| 7 | 6 |
"github.com/moby/moby/api/types/container" |
| 8 | 7 |
"gotest.tools/v3/assert" |
| 9 | 8 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -12,7 +11,7 @@ import ( |
| 12 | 12 |
// regression test for https://github.com/moby/moby/issues/45904 |
| 13 | 13 |
func TestContainerConfigToDockerImageConfig(t *testing.T) {
|
| 14 | 14 |
ociCFG := containerConfigToDockerOCIImageConfig(&container.Config{
|
| 15 |
- ExposedPorts: nat.PortSet{
|
|
| 15 |
+ ExposedPorts: container.PortSet{
|
|
| 16 | 16 |
"80/tcp": struct{}{},
|
| 17 | 17 |
}, |
| 18 | 18 |
}) |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/daemon/internal/image" |
| 10 | 10 |
"github.com/docker/docker/dockerversion" |
| 11 |
- "github.com/docker/go-connections/nat" |
|
| 12 | 11 |
imagespec "github.com/moby/docker-image-spec/specs-go/v1" |
| 13 | 12 |
"github.com/moby/moby/api/types/container" |
| 14 | 13 |
ocispec "github.com/opencontainers/image-spec/specs-go/v1" |
| ... | ... |
@@ -83,8 +82,8 @@ func containerConfigToDockerOCIImageConfig(cfg *container.Config) imagespec.Dock |
| 83 | 83 |
|
| 84 | 84 |
if len(cfg.ExposedPorts) > 0 {
|
| 85 | 85 |
ociCfg.ExposedPorts = map[string]struct{}{}
|
| 86 |
- for k, v := range cfg.ExposedPorts {
|
|
| 87 |
- ociCfg.ExposedPorts[string(k)] = v |
|
| 86 |
+ for k := range cfg.ExposedPorts {
|
|
| 87 |
+ ociCfg.ExposedPorts[string(k)] = struct{}{}
|
|
| 88 | 88 |
} |
| 89 | 89 |
} |
| 90 | 90 |
ext.Healthcheck = cfg.Healthcheck |
| ... | ... |
@@ -99,9 +98,9 @@ func containerConfigToDockerOCIImageConfig(cfg *container.Config) imagespec.Dock |
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
func dockerOCIImageConfigToContainerConfig(cfg imagespec.DockerOCIImageConfig) *container.Config {
|
| 102 |
- exposedPorts := make(nat.PortSet, len(cfg.ExposedPorts)) |
|
| 103 |
- for k, v := range cfg.ExposedPorts {
|
|
| 104 |
- exposedPorts[nat.Port(k)] = v |
|
| 102 |
+ exposedPorts := make(container.PortSet, len(cfg.ExposedPorts)) |
|
| 103 |
+ for k := range cfg.ExposedPorts {
|
|
| 104 |
+ exposedPorts[container.PortRangeProto(k)] = struct{}{}
|
|
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
return &container.Config{
|
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/daemon/internal/idtools" |
| 15 | 15 |
"github.com/docker/docker/daemon/libnetwork" |
| 16 | 16 |
volumesservice "github.com/docker/docker/daemon/volume/service" |
| 17 |
- "github.com/docker/go-connections/nat" |
|
| 18 | 17 |
containertypes "github.com/moby/moby/api/types/container" |
| 19 | 18 |
"github.com/pkg/errors" |
| 20 | 19 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -219,33 +218,28 @@ func TestContainerInitDNS(t *testing.T) {
|
| 219 | 219 |
} |
| 220 | 220 |
} |
| 221 | 221 |
|
| 222 |
-func newPortNoError(proto, port string) nat.Port {
|
|
| 223 |
- p, _ := nat.NewPort(proto, port) |
|
| 224 |
- return p |
|
| 225 |
-} |
|
| 226 |
- |
|
| 227 | 222 |
func TestMerge(t *testing.T) {
|
| 228 |
- volumesImage := make(map[string]struct{})
|
|
| 229 |
- volumesImage["/test1"] = struct{}{}
|
|
| 230 |
- volumesImage["/test2"] = struct{}{}
|
|
| 231 |
- portsImage := make(nat.PortSet) |
|
| 232 |
- portsImage[newPortNoError("tcp", "1111")] = struct{}{}
|
|
| 233 |
- portsImage[newPortNoError("tcp", "2222")] = struct{}{}
|
|
| 234 | 223 |
configImage := &containertypes.Config{
|
| 235 |
- ExposedPorts: portsImage, |
|
| 236 |
- Env: []string{"VAR1=1", "VAR2=2"},
|
|
| 237 |
- Volumes: volumesImage, |
|
| 224 |
+ ExposedPorts: containertypes.PortSet{
|
|
| 225 |
+ "1111/tcp": struct{}{},
|
|
| 226 |
+ "2222/tcp": struct{}{},
|
|
| 227 |
+ }, |
|
| 228 |
+ Env: []string{"VAR1=1", "VAR2=2"},
|
|
| 229 |
+ Volumes: map[string]struct{}{
|
|
| 230 |
+ "/test1": {},
|
|
| 231 |
+ "/test2": {},
|
|
| 232 |
+ }, |
|
| 238 | 233 |
} |
| 239 | 234 |
|
| 240 |
- portsUser := make(nat.PortSet) |
|
| 241 |
- portsUser[newPortNoError("tcp", "2222")] = struct{}{}
|
|
| 242 |
- portsUser[newPortNoError("tcp", "3333")] = struct{}{}
|
|
| 243 |
- volumesUser := make(map[string]struct{})
|
|
| 244 |
- volumesUser["/test3"] = struct{}{}
|
|
| 245 | 235 |
configUser := &containertypes.Config{
|
| 246 |
- ExposedPorts: portsUser, |
|
| 247 |
- Env: []string{"VAR2=3", "VAR3=3"},
|
|
| 248 |
- Volumes: volumesUser, |
|
| 236 |
+ ExposedPorts: containertypes.PortSet{
|
|
| 237 |
+ "2222/tcp": struct{}{},
|
|
| 238 |
+ "3333/tcp": struct{}{},
|
|
| 239 |
+ }, |
|
| 240 |
+ Env: []string{"VAR2=3", "VAR3=3"},
|
|
| 241 |
+ Volumes: map[string]struct{}{
|
|
| 242 |
+ "/test3": {},
|
|
| 243 |
+ }, |
|
| 249 | 244 |
} |
| 250 | 245 |
|
| 251 | 246 |
if err := merge(configUser, configImage); err != nil {
|
| ... | ... |
@@ -278,12 +272,8 @@ func TestMerge(t *testing.T) {
|
| 278 | 278 |
} |
| 279 | 279 |
} |
| 280 | 280 |
|
| 281 |
- ports, _, err := nat.ParsePortSpecs([]string{"0000"})
|
|
| 282 |
- if err != nil {
|
|
| 283 |
- t.Error(err) |
|
| 284 |
- } |
|
| 285 | 281 |
configImage2 := &containertypes.Config{
|
| 286 |
- ExposedPorts: ports, |
|
| 282 |
+ ExposedPorts: map[containertypes.PortRangeProto]struct{}{"0/tcp": {}},
|
|
| 287 | 283 |
} |
| 288 | 284 |
|
| 289 | 285 |
if err := merge(configUser, configImage2); err != nil {
|
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/daemon/network" |
| 15 | 15 |
"github.com/docker/docker/daemon/server/backend" |
| 16 | 16 |
"github.com/docker/docker/errdefs" |
| 17 |
- "github.com/docker/go-connections/nat" |
|
| 18 | 17 |
containertypes "github.com/moby/moby/api/types/container" |
| 19 | 18 |
networktypes "github.com/moby/moby/api/types/network" |
| 20 | 19 |
) |
| ... | ... |
@@ -60,7 +59,7 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, options |
| 60 | 60 |
Networks: apiNetworks, |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
- ports := make(nat.PortMap, len(ctr.NetworkSettings.Ports)) |
|
| 63 |
+ ports := make(containertypes.PortMap, len(ctr.NetworkSettings.Ports)) |
|
| 64 | 64 |
for k, pm := range ctr.NetworkSettings.Ports {
|
| 65 | 65 |
ports[k] = pm |
| 66 | 66 |
} |
| ... | ... |
@@ -4,37 +4,36 @@ import ( |
| 4 | 4 |
"runtime" |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/go-connections/nat" |
|
| 8 | 7 |
"github.com/moby/moby/api/types/container" |
| 9 | 8 |
ocispec "github.com/opencontainers/image-spec/specs-go/v1" |
| 10 | 9 |
"gotest.tools/v3/assert" |
| 11 | 10 |
is "gotest.tools/v3/assert/cmp" |
| 12 | 11 |
) |
| 13 | 12 |
|
| 14 |
-// Just to make life easier |
|
| 15 |
-func newPortNoError(proto, port string) nat.Port {
|
|
| 16 |
- p, _ := nat.NewPort(proto, port) |
|
| 17 |
- return p |
|
| 18 |
-} |
|
| 19 |
- |
|
| 20 | 13 |
func TestCompare(t *testing.T) {
|
| 21 |
- ports1 := make(nat.PortSet) |
|
| 22 |
- ports1[newPortNoError("tcp", "1111")] = struct{}{}
|
|
| 23 |
- ports1[newPortNoError("tcp", "2222")] = struct{}{}
|
|
| 24 |
- ports2 := make(nat.PortSet) |
|
| 25 |
- ports2[newPortNoError("tcp", "3333")] = struct{}{}
|
|
| 26 |
- ports2[newPortNoError("tcp", "4444")] = struct{}{}
|
|
| 27 |
- ports3 := make(nat.PortSet) |
|
| 28 |
- ports3[newPortNoError("tcp", "1111")] = struct{}{}
|
|
| 29 |
- ports3[newPortNoError("tcp", "2222")] = struct{}{}
|
|
| 30 |
- ports3[newPortNoError("tcp", "5555")] = struct{}{}
|
|
| 31 |
- volumes1 := make(map[string]struct{})
|
|
| 32 |
- volumes1["/test1"] = struct{}{}
|
|
| 33 |
- volumes2 := make(map[string]struct{})
|
|
| 34 |
- volumes2["/test2"] = struct{}{}
|
|
| 35 |
- volumes3 := make(map[string]struct{})
|
|
| 36 |
- volumes3["/test1"] = struct{}{}
|
|
| 37 |
- volumes3["/test3"] = struct{}{}
|
|
| 14 |
+ ports1 := container.PortSet{
|
|
| 15 |
+ "1111/tcp": struct{}{},
|
|
| 16 |
+ "2222/tcp": struct{}{},
|
|
| 17 |
+ } |
|
| 18 |
+ ports2 := container.PortSet{
|
|
| 19 |
+ "3333/tcp": struct{}{},
|
|
| 20 |
+ "4444/tcp": struct{}{},
|
|
| 21 |
+ } |
|
| 22 |
+ ports3 := container.PortSet{
|
|
| 23 |
+ "1111/tcp": struct{}{},
|
|
| 24 |
+ "2222/tcp": struct{}{},
|
|
| 25 |
+ "5555/tcp": struct{}{},
|
|
| 26 |
+ } |
|
| 27 |
+ volumes1 := map[string]struct{}{
|
|
| 28 |
+ "/test1": {},
|
|
| 29 |
+ } |
|
| 30 |
+ volumes2 := map[string]struct{}{
|
|
| 31 |
+ "/test2": {},
|
|
| 32 |
+ } |
|
| 33 |
+ volumes3 := map[string]struct{}{
|
|
| 34 |
+ "/test1": {},
|
|
| 35 |
+ "/test3": {},
|
|
| 36 |
+ } |
|
| 38 | 37 |
envs1 := []string{"ENV1=value1", "ENV2=value2"}
|
| 39 | 38 |
envs2 := []string{"ENV1=value1", "ENV3=value3"}
|
| 40 | 39 |
entrypoint1 := []string{"/bin/sh", "-c"}
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/go-connections/nat" |
| 9 |
+ "github.com/moby/moby/api/types/container" |
|
| 9 | 10 |
) |
| 10 | 11 |
|
| 11 | 12 |
// Link struct holds information about parent/child linked container |
| ... | ... |
@@ -19,18 +20,18 @@ type Link struct {
|
| 19 | 19 |
// Child environments variables |
| 20 | 20 |
ChildEnvironment []string |
| 21 | 21 |
// Child exposed ports |
| 22 |
- Ports []nat.Port |
|
| 22 |
+ Ports []container.PortRangeProto // TODO(thaJeztah): can we use []string here, or do we need the features of nat.Port? |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
// EnvVars generates environment variables for the linked container |
| 26 | 26 |
// for the Link with the given options. |
| 27 |
-func EnvVars(parentIP, childIP, name string, env []string, exposedPorts map[nat.Port]struct{}) []string {
|
|
| 27 |
+func EnvVars(parentIP, childIP, name string, env []string, exposedPorts map[container.PortRangeProto]struct{}) []string {
|
|
| 28 | 28 |
return NewLink(parentIP, childIP, name, env, exposedPorts).ToEnv() |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 | 31 |
// NewLink initializes a new Link struct with the provided options. |
| 32 |
-func NewLink(parentIP, childIP, name string, env []string, exposedPorts map[nat.Port]struct{}) *Link {
|
|
| 33 |
- ports := make([]nat.Port, 0, len(exposedPorts)) |
|
| 32 |
+func NewLink(parentIP, childIP, name string, env []string, exposedPorts map[container.PortRangeProto]struct{}) *Link {
|
|
| 33 |
+ ports := make([]container.PortRangeProto, 0, len(exposedPorts)) |
|
| 34 | 34 |
for p := range exposedPorts {
|
| 35 | 35 |
ports = append(ports, p) |
| 36 | 36 |
} |
| ... | ... |
@@ -54,7 +55,7 @@ func (l *Link) ToEnv() []string {
|
| 54 | 54 |
// sort the ports so that we can bulk the continuous ports together |
| 55 | 55 |
nat.Sort(l.Ports, withTCPPriority) |
| 56 | 56 |
|
| 57 |
- var pStart, pEnd nat.Port |
|
| 57 |
+ var pStart, pEnd container.PortRangeProto |
|
| 58 | 58 |
env := make([]string, 0, 1+len(l.Ports)*4) |
| 59 | 59 |
for i, p := range l.Ports {
|
| 60 | 60 |
if i == 0 {
|
| ... | ... |
@@ -112,7 +113,7 @@ func (l *Link) ToEnv() []string {
|
| 112 | 112 |
|
| 113 | 113 |
// withTCPPriority prioritizes ports using TCP over other protocols before |
| 114 | 114 |
// comparing port-number and protocol. |
| 115 |
-func withTCPPriority(ip, jp nat.Port) bool {
|
|
| 115 |
+func withTCPPriority(ip, jp container.PortRangeProto) bool {
|
|
| 116 | 116 |
if strings.EqualFold(ip.Proto(), jp.Proto()) {
|
| 117 | 117 |
return ip.Int() < jp.Int() |
| 118 | 118 |
} |
| ... | ... |
@@ -5,11 +5,12 @@ import ( |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/go-connections/nat" |
| 8 |
+ "github.com/moby/moby/api/types/container" |
|
| 8 | 9 |
"gotest.tools/v3/assert" |
| 9 | 10 |
) |
| 10 | 11 |
|
| 11 | 12 |
func TestLinkNaming(t *testing.T) {
|
| 12 |
- actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker-1", nil, nat.PortSet{
|
|
| 13 |
+ actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker-1", nil, container.PortSet{
|
|
| 13 | 14 |
"6379/tcp": struct{}{},
|
| 14 | 15 |
}) |
| 15 | 16 |
|
| ... | ... |
@@ -27,7 +28,7 @@ func TestLinkNaming(t *testing.T) {
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
func TestLinkNew(t *testing.T) {
|
| 30 |
- link := NewLink("172.0.17.3", "172.0.17.2", "/db/docker", nil, nat.PortSet{
|
|
| 30 |
+ link := NewLink("172.0.17.3", "172.0.17.2", "/db/docker", nil, container.PortSet{
|
|
| 31 | 31 |
"6379/tcp": struct{}{},
|
| 32 | 32 |
}) |
| 33 | 33 |
|
| ... | ... |
@@ -35,14 +36,14 @@ func TestLinkNew(t *testing.T) {
|
| 35 | 35 |
Name: "/db/docker", |
| 36 | 36 |
ParentIP: "172.0.17.3", |
| 37 | 37 |
ChildIP: "172.0.17.2", |
| 38 |
- Ports: []nat.Port{"6379/tcp"},
|
|
| 38 |
+ Ports: []container.PortRangeProto{"6379/tcp"},
|
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 | 41 |
assert.DeepEqual(t, expected, link) |
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 | 44 |
func TestLinkEnv(t *testing.T) {
|
| 45 |
- actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, nat.PortSet{
|
|
| 45 |
+ actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, container.PortSet{
|
|
| 46 | 46 |
"6379/tcp": struct{}{},
|
| 47 | 47 |
}) |
| 48 | 48 |
|
| ... | ... |
@@ -63,7 +64,7 @@ func TestLinkEnv(t *testing.T) {
|
| 63 | 63 |
// TestSortPorts verifies that ports are sorted with TCP taking priority, |
| 64 | 64 |
// and ports with the same protocol to be sorted by port. |
| 65 | 65 |
func TestSortPorts(t *testing.T) {
|
| 66 |
- ports := []nat.Port{
|
|
| 66 |
+ ports := []container.PortRangeProto{
|
|
| 67 | 67 |
"6379/tcp", |
| 68 | 68 |
"6376/udp", |
| 69 | 69 |
"6380/tcp", |
| ... | ... |
@@ -74,7 +75,7 @@ func TestSortPorts(t *testing.T) {
|
| 74 | 74 |
"6375/sctp", |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
- expected := []nat.Port{
|
|
| 77 |
+ expected := []container.PortRangeProto{
|
|
| 78 | 78 |
"6379/tcp", |
| 79 | 79 |
"6380/tcp", |
| 80 | 80 |
"6381/tcp", |
| ... | ... |
@@ -90,7 +91,7 @@ func TestSortPorts(t *testing.T) {
|
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 | 92 |
func TestLinkMultipleEnv(t *testing.T) {
|
| 93 |
- actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, nat.PortSet{
|
|
| 93 |
+ actual := EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, container.PortSet{
|
|
| 94 | 94 |
"6300/udp": struct{}{},
|
| 95 | 95 |
"6379/tcp": struct{}{},
|
| 96 | 96 |
"6380/tcp": struct{}{},
|
| ... | ... |
@@ -141,7 +142,7 @@ func BenchmarkLinkMultipleEnv(b *testing.B) {
|
| 141 | 141 |
b.ReportAllocs() |
| 142 | 142 |
b.ResetTimer() |
| 143 | 143 |
for i := 0; i < b.N; i++ {
|
| 144 |
- _ = EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, nat.PortSet{
|
|
| 144 |
+ _ = EnvVars("172.0.17.3", "172.0.17.2", "/db/docker", []string{"PASSWORD=gordon"}, container.PortSet{
|
|
| 145 | 145 |
"6300/udp": struct{}{},
|
| 146 | 146 |
"6379/tcp": struct{}{},
|
| 147 | 147 |
"6380/tcp": struct{}{},
|
| ... | ... |
@@ -84,9 +84,9 @@ type listContext struct {
|
| 84 | 84 |
isTask bool |
| 85 | 85 |
|
| 86 | 86 |
// publish is a list of published ports to filter with |
| 87 |
- publish map[nat.Port]bool |
|
| 87 |
+ publish map[containertypes.PortRangeProto]bool // TODO(thaJeztah): could this be a straight map[string]bool? |
|
| 88 | 88 |
// expose is a list of exposed ports to filter with |
| 89 |
- expose map[nat.Port]bool |
|
| 89 |
+ expose map[containertypes.PortRangeProto]bool // TODO(thaJeztah): could this be a straight map[string]bool? |
|
| 90 | 90 |
|
| 91 | 91 |
// ListOptions is the filters set by the user |
| 92 | 92 |
*containertypes.ListOptions |
| ... | ... |
@@ -346,13 +346,13 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf |
| 346 | 346 |
} |
| 347 | 347 |
} |
| 348 | 348 |
|
| 349 |
- publishFilter := map[nat.Port]bool{}
|
|
| 349 |
+ publishFilter := map[containertypes.PortRangeProto]bool{}
|
|
| 350 | 350 |
err = psFilters.WalkValues("publish", portOp("publish", publishFilter))
|
| 351 | 351 |
if err != nil {
|
| 352 | 352 |
return nil, err |
| 353 | 353 |
} |
| 354 | 354 |
|
| 355 |
- exposeFilter := map[nat.Port]bool{}
|
|
| 355 |
+ exposeFilter := map[containertypes.PortRangeProto]bool{}
|
|
| 356 | 356 |
err = psFilters.WalkValues("expose", portOp("expose", exposeFilter))
|
| 357 | 357 |
if err != nil {
|
| 358 | 358 |
return nil, err |
| ... | ... |
@@ -397,7 +397,7 @@ func idOrNameFilter(view *container.View, value string) (*container.Snapshot, er |
| 397 | 397 |
return filter, err |
| 398 | 398 |
} |
| 399 | 399 |
|
| 400 |
-func portOp(key string, filter map[nat.Port]bool) func(value string) error {
|
|
| 400 |
+func portOp(key string, filter map[containertypes.PortRangeProto]bool) func(value string) error {
|
|
| 401 | 401 |
return func(value string) error {
|
| 402 | 402 |
if strings.Contains(value, ":") {
|
| 403 | 403 |
return fmt.Errorf("filter for '%s' should not contain ':': %s", key, value)
|
| ... | ... |
@@ -568,12 +568,12 @@ func includeContainerInList(container *container.Snapshot, filter *listContext) |
| 568 | 568 |
if len(filter.expose) > 0 || len(filter.publish) > 0 {
|
| 569 | 569 |
var ( |
| 570 | 570 |
shouldSkip = true |
| 571 |
- publishedPort nat.Port |
|
| 572 |
- exposedPort nat.Port |
|
| 571 |
+ publishedPort containertypes.PortRangeProto |
|
| 572 |
+ exposedPort containertypes.PortRangeProto |
|
| 573 | 573 |
) |
| 574 | 574 |
for _, port := range container.Ports {
|
| 575 |
- publishedPort = nat.Port(fmt.Sprintf("%d/%s", port.PublicPort, port.Type))
|
|
| 576 |
- exposedPort = nat.Port(fmt.Sprintf("%d/%s", port.PrivatePort, port.Type))
|
|
| 575 |
+ publishedPort = containertypes.PortRangeProto(fmt.Sprintf("%d/%s", port.PublicPort, port.Type))
|
|
| 576 |
+ exposedPort = containertypes.PortRangeProto(fmt.Sprintf("%d/%s", port.PrivatePort, port.Type))
|
|
| 577 | 577 |
if ok := filter.publish[publishedPort]; ok {
|
| 578 | 578 |
shouldSkip = false |
| 579 | 579 |
break |
| ... | ... |
@@ -944,12 +944,12 @@ func buildPortsRelatedCreateEndpointOptions(c *container.Container, n *libnetwor |
| 944 | 944 |
return nil, nil |
| 945 | 945 |
} |
| 946 | 946 |
|
| 947 |
- bindings := make(nat.PortMap) |
|
| 947 |
+ bindings := make(containertypes.PortMap) |
|
| 948 | 948 |
if c.HostConfig.PortBindings != nil {
|
| 949 | 949 |
for p, b := range c.HostConfig.PortBindings {
|
| 950 |
- bindings[p] = []nat.PortBinding{}
|
|
| 950 |
+ bindings[p] = []containertypes.PortBinding{}
|
|
| 951 | 951 |
for _, bb := range b {
|
| 952 |
- bindings[p] = append(bindings[p], nat.PortBinding{
|
|
| 952 |
+ bindings[p] = append(bindings[p], containertypes.PortBinding{
|
|
| 953 | 953 |
HostIP: bb.HostIP, |
| 954 | 954 |
HostPort: bb.HostPort, |
| 955 | 955 |
}) |
| ... | ... |
@@ -958,7 +958,7 @@ func buildPortsRelatedCreateEndpointOptions(c *container.Container, n *libnetwor |
| 958 | 958 |
} |
| 959 | 959 |
|
| 960 | 960 |
// TODO(thaJeztah): Move this code to a method on nat.PortSet. |
| 961 |
- ports := make([]nat.Port, 0, len(c.Config.ExposedPorts)) |
|
| 961 |
+ ports := make([]containertypes.PortRangeProto, 0, len(c.Config.ExposedPorts)) |
|
| 962 | 962 |
for p := range c.Config.ExposedPorts {
|
| 963 | 963 |
ports = append(ports, p) |
| 964 | 964 |
} |
| ... | ... |
@@ -1009,8 +1009,8 @@ func buildPortsRelatedCreateEndpointOptions(c *container.Container, n *libnetwor |
| 1009 | 1009 |
} |
| 1010 | 1010 |
|
| 1011 | 1011 |
// getPortMapInfo retrieves the current port-mapping programmed for the given sandbox |
| 1012 |
-func getPortMapInfo(sb *libnetwork.Sandbox) nat.PortMap {
|
|
| 1013 |
- pm := nat.PortMap{}
|
|
| 1012 |
+func getPortMapInfo(sb *libnetwork.Sandbox) containertypes.PortMap {
|
|
| 1013 |
+ pm := containertypes.PortMap{}
|
|
| 1014 | 1014 |
if sb == nil {
|
| 1015 | 1015 |
return pm |
| 1016 | 1016 |
} |
| ... | ... |
@@ -1021,7 +1021,7 @@ func getPortMapInfo(sb *libnetwork.Sandbox) nat.PortMap {
|
| 1021 | 1021 |
return pm |
| 1022 | 1022 |
} |
| 1023 | 1023 |
|
| 1024 |
-func getEndpointPortMapInfo(pm nat.PortMap, ep *libnetwork.Endpoint) {
|
|
| 1024 |
+func getEndpointPortMapInfo(pm containertypes.PortMap, ep *libnetwork.Endpoint) {
|
|
| 1025 | 1025 |
driverInfo, _ := ep.DriverInfo() |
| 1026 | 1026 |
if driverInfo == nil {
|
| 1027 | 1027 |
// It is not an error for epInfo to be nil |
| ... | ... |
@@ -1060,7 +1060,7 @@ func getEndpointPortMapInfo(pm nat.PortMap, ep *libnetwork.Endpoint) {
|
| 1060 | 1060 |
if pp.HostPort > 0 {
|
| 1061 | 1061 |
hp = strconv.Itoa(int(pp.HostPort)) |
| 1062 | 1062 |
} |
| 1063 |
- natBndg := nat.PortBinding{HostIP: pp.HostIP.String(), HostPort: hp}
|
|
| 1063 |
+ natBndg := containertypes.PortBinding{HostIP: pp.HostIP.String(), HostPort: hp}
|
|
| 1064 | 1064 |
pm[natPort] = append(pm[natPort], natBndg) |
| 1065 | 1065 |
} |
| 1066 | 1066 |
} |
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 | 7 |
clustertypes "github.com/docker/docker/daemon/cluster/provider" |
| 8 |
- "github.com/docker/go-connections/nat" |
|
| 8 |
+ "github.com/moby/moby/api/types/container" |
|
| 9 | 9 |
networktypes "github.com/moby/moby/api/types/network" |
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
) |
| ... | ... |
@@ -21,7 +21,7 @@ type Settings struct {
|
| 21 | 21 |
LinkLocalIPv6PrefixLen int |
| 22 | 22 |
Networks map[string]*EndpointSettings |
| 23 | 23 |
Service *clustertypes.ServiceConfig |
| 24 |
- Ports nat.PortMap |
|
| 24 |
+ Ports container.PortMap |
|
| 25 | 25 |
SecondaryIPAddresses []networktypes.Address |
| 26 | 26 |
SecondaryIPv6Addresses []networktypes.Address |
| 27 | 27 |
HasSwarmEndpoint bool |
| ... | ... |
@@ -22,7 +22,6 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/integration-cli/cli/build" |
| 23 | 23 |
"github.com/docker/docker/testutil" |
| 24 | 24 |
"github.com/docker/docker/testutil/request" |
| 25 |
- "github.com/docker/go-connections/nat" |
|
| 26 | 25 |
"github.com/moby/moby/api/types/container" |
| 27 | 26 |
"github.com/moby/moby/api/types/mount" |
| 28 | 27 |
"github.com/moby/moby/api/types/network" |
| ... | ... |
@@ -505,8 +504,8 @@ func (s *DockerAPISuite) TestContainerAPIBadPort(c *testing.T) {
|
| 505 | 505 |
} |
| 506 | 506 |
|
| 507 | 507 |
hostConfig := container.HostConfig{
|
| 508 |
- PortBindings: nat.PortMap{
|
|
| 509 |
- "8080/tcp": []nat.PortBinding{
|
|
| 508 |
+ PortBindings: container.PortMap{
|
|
| 509 |
+ "8080/tcp": []container.PortBinding{
|
|
| 510 | 510 |
{
|
| 511 | 511 |
HostIP: "", |
| 512 | 512 |
HostPort: "aa80", |
| ... | ... |
@@ -12,7 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/integration-cli/cli" |
| 13 | 13 |
"github.com/docker/docker/integration-cli/cli/build" |
| 14 | 14 |
"github.com/docker/docker/testutil/fakecontext" |
| 15 |
- "github.com/docker/go-connections/nat" |
|
| 15 |
+ containertypes "github.com/moby/moby/api/types/container" |
|
| 16 | 16 |
"gotest.tools/v3/assert" |
| 17 | 17 |
is "gotest.tools/v3/assert/cmp" |
| 18 | 18 |
) |
| ... | ... |
@@ -92,7 +92,7 @@ func (s *DockerCLICreateSuite) TestCreateWithPortRange(c *testing.T) {
|
| 92 | 92 |
|
| 93 | 93 |
var containers []struct {
|
| 94 | 94 |
HostConfig *struct {
|
| 95 |
- PortBindings map[nat.Port][]nat.PortBinding |
|
| 95 |
+ PortBindings map[containertypes.PortRangeProto][]containertypes.PortBinding |
|
| 96 | 96 |
} |
| 97 | 97 |
} |
| 98 | 98 |
err := json.Unmarshal([]byte(out), &containers) |
| ... | ... |
@@ -118,7 +118,7 @@ func (s *DockerCLICreateSuite) TestCreateWithLargePortRange(c *testing.T) {
|
| 118 | 118 |
|
| 119 | 119 |
var containers []struct {
|
| 120 | 120 |
HostConfig *struct {
|
| 121 |
- PortBindings map[nat.Port][]nat.PortBinding |
|
| 121 |
+ PortBindings map[containertypes.PortRangeProto][]containertypes.PortBinding |
|
| 122 | 122 |
} |
| 123 | 123 |
} |
| 124 | 124 |
|
| ... | ... |
@@ -30,7 +30,7 @@ import ( |
| 30 | 30 |
"github.com/docker/docker/testutil" |
| 31 | 31 |
testdaemon "github.com/docker/docker/testutil/daemon" |
| 32 | 32 |
"github.com/docker/docker/testutil/fakecontext" |
| 33 |
- "github.com/docker/go-connections/nat" |
|
| 33 |
+ "github.com/moby/moby/api/types/container" |
|
| 34 | 34 |
"github.com/moby/moby/client" |
| 35 | 35 |
"github.com/moby/moby/client/pkg/stringid" |
| 36 | 36 |
"github.com/moby/sys/mountinfo" |
| ... | ... |
@@ -2169,7 +2169,7 @@ func (s *DockerCLIRunSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) {
|
| 2169 | 2169 |
id = strings.TrimSpace(id) |
| 2170 | 2170 |
|
| 2171 | 2171 |
portstr := inspectFieldJSON(c, id, "NetworkSettings.Ports") |
| 2172 |
- var ports nat.PortMap |
|
| 2172 |
+ var ports container.PortMap |
|
| 2173 | 2173 |
if err := json.Unmarshal([]byte(portstr), &ports); err != nil {
|
| 2174 | 2174 |
c.Fatal(err) |
| 2175 | 2175 |
} |
| ... | ... |
@@ -2502,7 +2502,7 @@ func (s *DockerCLIRunSuite) TestRunAllowPortRangeThroughPublish(c *testing.T) {
|
| 2502 | 2502 |
id = strings.TrimSpace(id) |
| 2503 | 2503 |
portStr := inspectFieldJSON(c, id, "NetworkSettings.Ports") |
| 2504 | 2504 |
|
| 2505 |
- var ports nat.PortMap |
|
| 2505 |
+ var ports container.PortMap |
|
| 2506 | 2506 |
err := json.Unmarshal([]byte(portStr), &ports) |
| 2507 | 2507 |
assert.NilError(c, err, "failed to unmarshal: %v", portStr) |
| 2508 | 2508 |
for port, binding := range ports {
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"github.com/docker/docker/integration/internal/container" |
| 7 | 7 |
"github.com/docker/docker/testutil" |
| 8 | 8 |
"github.com/docker/docker/testutil/daemon" |
| 9 |
- "github.com/docker/go-connections/nat" |
|
| 10 | 9 |
containertypes "github.com/moby/moby/api/types/container" |
| 11 | 10 |
"gotest.tools/v3/assert" |
| 12 | 11 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -76,7 +75,7 @@ func TestNetworkStateCleanupOnDaemonStart(t *testing.T) {
|
| 76 | 76 |
// Sadly this means the test will take longer, but at least this test can be parallelized. |
| 77 | 77 |
cid := container.Run(ctx, t, apiClient, |
| 78 | 78 |
container.WithExposedPorts("80/tcp"),
|
| 79 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{}}}),
|
|
| 79 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{}}}),
|
|
| 80 | 80 |
container.WithCmd("/bin/sh", "-c", "while true; do echo hello; sleep 1; done"))
|
| 81 | 81 |
defer func() {
|
| 82 | 82 |
err := apiClient.ContainerRemove(ctx, cid, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/integration/internal/container" |
| 14 |
- "github.com/docker/go-connections/nat" |
|
| 15 | 14 |
containertypes "github.com/moby/moby/api/types/container" |
| 16 | 15 |
"gotest.tools/v3/assert" |
| 17 | 16 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -122,8 +121,8 @@ func startServerContainer(ctx context.Context, t *testing.T, msg string, port in |
| 122 | 122 |
container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)),
|
| 123 | 123 |
container.WithExposedPorts(fmt.Sprintf("%d/tcp", port)),
|
| 124 | 124 |
func(c *container.TestContainerConfig) {
|
| 125 |
- c.HostConfig.PortBindings = nat.PortMap{
|
|
| 126 |
- nat.Port(fmt.Sprintf("%d/tcp", port)): []nat.PortBinding{
|
|
| 125 |
+ c.HostConfig.PortBindings = containertypes.PortMap{
|
|
| 126 |
+ containertypes.PortRangeProto(fmt.Sprintf("%d/tcp", port)): []containertypes.PortBinding{
|
|
| 127 | 127 |
{
|
| 128 | 128 |
HostPort: fmt.Sprintf("%d", port),
|
| 129 | 129 |
}, |
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"slices" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/go-connections/nat" |
|
| 9 | 8 |
"github.com/moby/moby/api/types/container" |
| 10 | 9 |
"github.com/moby/moby/api/types/mount" |
| 11 | 10 |
"github.com/moby/moby/api/types/network" |
| ... | ... |
@@ -74,17 +73,17 @@ func WithSysctls(sysctls map[string]string) func(*TestContainerConfig) {
|
| 74 | 74 |
// WithExposedPorts sets the exposed ports of the container |
| 75 | 75 |
func WithExposedPorts(ports ...string) func(*TestContainerConfig) {
|
| 76 | 76 |
return func(c *TestContainerConfig) {
|
| 77 |
- c.Config.ExposedPorts = map[nat.Port]struct{}{}
|
|
| 77 |
+ c.Config.ExposedPorts = map[container.PortRangeProto]struct{}{}
|
|
| 78 | 78 |
for _, port := range ports {
|
| 79 |
- c.Config.ExposedPorts[nat.Port(port)] = struct{}{}
|
|
| 79 |
+ c.Config.ExposedPorts[container.PortRangeProto(port)] = struct{}{}
|
|
| 80 | 80 |
} |
| 81 | 81 |
} |
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
// WithPortMap sets/replaces port mappings. |
| 85 |
-func WithPortMap(pm nat.PortMap) func(*TestContainerConfig) {
|
|
| 85 |
+func WithPortMap(pm container.PortMap) func(*TestContainerConfig) {
|
|
| 86 | 86 |
return func(c *TestContainerConfig) {
|
| 87 |
- c.HostConfig.PortBindings = nat.PortMap{}
|
|
| 87 |
+ c.HostConfig.PortBindings = container.PortMap{}
|
|
| 88 | 88 |
for p, b := range pm {
|
| 89 | 89 |
c.HostConfig.PortBindings[p] = slices.Clone(b) |
| 90 | 90 |
} |
| ... | ... |
@@ -17,7 +17,6 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/integration/internal/testutils/networking" |
| 18 | 18 |
"github.com/docker/docker/testutil" |
| 19 | 19 |
"github.com/docker/docker/testutil/daemon" |
| 20 |
- "github.com/docker/go-connections/nat" |
|
| 21 | 20 |
containertypes "github.com/moby/moby/api/types/container" |
| 22 | 21 |
networktypes "github.com/moby/moby/api/types/network" |
| 23 | 22 |
"github.com/moby/moby/api/types/versions" |
| ... | ... |
@@ -519,14 +518,14 @@ func TestPublishedPortAlreadyInUse(t *testing.T) {
|
| 519 | 519 |
ctr1 := ctr.Run(ctx, t, apiClient, |
| 520 | 520 |
ctr.WithCmd("top"),
|
| 521 | 521 |
ctr.WithExposedPorts("80/tcp"),
|
| 522 |
- ctr.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 522 |
+ ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 523 | 523 |
defer ctr.Remove(ctx, t, apiClient, ctr1, containertypes.RemoveOptions{Force: true})
|
| 524 | 524 |
|
| 525 | 525 |
ctr2 := ctr.Create(ctx, t, apiClient, |
| 526 | 526 |
ctr.WithCmd("top"),
|
| 527 | 527 |
ctr.WithRestartPolicy(containertypes.RestartPolicyAlways), |
| 528 | 528 |
ctr.WithExposedPorts("80/tcp"),
|
| 529 |
- ctr.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 529 |
+ ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 530 | 530 |
defer ctr.Remove(ctx, t, apiClient, ctr2, containertypes.RemoveOptions{Force: true})
|
| 531 | 531 |
|
| 532 | 532 |
err := apiClient.ContainerStart(ctx, ctr2, containertypes.StartOptions{})
|
| ... | ... |
@@ -561,14 +560,14 @@ func TestAllPortMappingsAreReturned(t *testing.T) {
|
| 561 | 561 |
|
| 562 | 562 |
ctrID := ctr.Run(ctx, t, apiClient, |
| 563 | 563 |
ctr.WithExposedPorts("80/tcp", "81/tcp"),
|
| 564 |
- ctr.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8000"}}}),
|
|
| 564 |
+ ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}),
|
|
| 565 | 565 |
ctr.WithEndpointSettings("testnetv4", &networktypes.EndpointSettings{}),
|
| 566 | 566 |
ctr.WithEndpointSettings("testnetv6", &networktypes.EndpointSettings{}))
|
| 567 | 567 |
defer ctr.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
| 568 | 568 |
|
| 569 | 569 |
inspect := ctr.Inspect(ctx, t, apiClient, ctrID) |
| 570 |
- assert.DeepEqual(t, inspect.NetworkSettings.Ports, nat.PortMap{
|
|
| 571 |
- "80/tcp": []nat.PortBinding{
|
|
| 570 |
+ assert.DeepEqual(t, inspect.NetworkSettings.Ports, containertypes.PortMap{
|
|
| 571 |
+ "80/tcp": []containertypes.PortBinding{
|
|
| 572 | 572 |
{HostIP: "0.0.0.0", HostPort: "8000"},
|
| 573 | 573 |
{HostIP: "::", HostPort: "8000"},
|
| 574 | 574 |
}, |
| ... | ... |
@@ -600,7 +599,7 @@ func TestFirewalldReloadNoZombies(t *testing.T) {
|
| 600 | 600 |
|
| 601 | 601 |
cid := ctr.Run(ctx, t, c, |
| 602 | 602 |
ctr.WithExposedPorts("80/tcp", "81/tcp"),
|
| 603 |
- ctr.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 603 |
+ ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
|
| 604 | 604 |
defer func() {
|
| 605 | 605 |
if !removed {
|
| 606 | 606 |
ctr.Remove(ctx, t, c, cid, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -790,7 +789,7 @@ func TestPortMappingRestore(t *testing.T) {
|
| 790 | 790 |
const svrName = "svr" |
| 791 | 791 |
cid := ctr.Run(ctx, t, c, |
| 792 | 792 |
ctr.WithExposedPorts("80/tcp"),
|
| 793 |
- ctr.WithPortMap(nat.PortMap{"80/tcp": {}}),
|
|
| 793 |
+ ctr.WithPortMap(containertypes.PortMap{"80/tcp": {}}),
|
|
| 794 | 794 |
ctr.WithName(svrName), |
| 795 | 795 |
ctr.WithRestartPolicy(containertypes.RestartPolicyUnlessStopped), |
| 796 | 796 |
ctr.WithCmd("httpd", "-f"),
|
| ... | ... |
@@ -801,7 +800,7 @@ func TestPortMappingRestore(t *testing.T) {
|
| 801 | 801 |
t.Helper() |
| 802 | 802 |
insp := ctr.Inspect(ctx, t, c, cid) |
| 803 | 803 |
assert.Check(t, is.Equal(insp.State.Running, true)) |
| 804 |
- if assert.Check(t, is.Contains(insp.NetworkSettings.Ports, nat.Port("80/tcp"))) &&
|
|
| 804 |
+ if assert.Check(t, is.Contains(insp.NetworkSettings.Ports, containertypes.PortRangeProto("80/tcp"))) &&
|
|
| 805 | 805 |
assert.Check(t, is.Len(insp.NetworkSettings.Ports["80/tcp"], 2)) {
|
| 806 | 806 |
hostPort := insp.NetworkSettings.Ports["80/tcp"][0].HostPort |
| 807 | 807 |
res := ctr.RunAttach(ctx, t, c, |
| ... | ... |
@@ -36,7 +36,6 @@ import ( |
| 36 | 36 |
"github.com/docker/docker/integration/internal/testutils/networking" |
| 37 | 37 |
"github.com/docker/docker/testutil" |
| 38 | 38 |
"github.com/docker/docker/testutil/daemon" |
| 39 |
- "github.com/docker/go-connections/nat" |
|
| 40 | 39 |
containertypes "github.com/moby/moby/api/types/container" |
| 41 | 40 |
networktypes "github.com/moby/moby/api/types/network" |
| 42 | 41 |
swarmtypes "github.com/moby/moby/api/types/swarm" |
| ... | ... |
@@ -55,7 +54,7 @@ var ( |
| 55 | 55 |
|
| 56 | 56 |
type ctrDesc struct {
|
| 57 | 57 |
name string |
| 58 |
- portMappings nat.PortMap |
|
| 58 |
+ portMappings containertypes.PortMap |
|
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 | 61 |
type networkDesc struct {
|
| ... | ... |
@@ -84,7 +83,7 @@ var index = []section{
|
| 84 | 84 |
containers: []ctrDesc{
|
| 85 | 85 |
{
|
| 86 | 86 |
name: "c1", |
| 87 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 87 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 88 | 88 |
}, |
| 89 | 89 |
}, |
| 90 | 90 |
}}, |
| ... | ... |
@@ -97,7 +96,7 @@ var index = []section{
|
| 97 | 97 |
containers: []ctrDesc{
|
| 98 | 98 |
{
|
| 99 | 99 |
name: "c1", |
| 100 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 100 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 101 | 101 |
}, |
| 102 | 102 |
}, |
| 103 | 103 |
}}, |
| ... | ... |
@@ -110,7 +109,7 @@ var index = []section{
|
| 110 | 110 |
containers: []ctrDesc{
|
| 111 | 111 |
{
|
| 112 | 112 |
name: "c1", |
| 113 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 113 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 114 | 114 |
}, |
| 115 | 115 |
}, |
| 116 | 116 |
}}, |
| ... | ... |
@@ -144,7 +143,7 @@ var index = []section{
|
| 144 | 144 |
containers: []ctrDesc{
|
| 145 | 145 |
{
|
| 146 | 146 |
name: "c1", |
| 147 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 147 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 148 | 148 |
}, |
| 149 | 149 |
}, |
| 150 | 150 |
}}, |
| ... | ... |
@@ -157,7 +156,7 @@ var index = []section{
|
| 157 | 157 |
containers: []ctrDesc{
|
| 158 | 158 |
{
|
| 159 | 159 |
name: "c1", |
| 160 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 160 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 161 | 161 |
}, |
| 162 | 162 |
}, |
| 163 | 163 |
}}, |
| ... | ... |
@@ -169,7 +168,7 @@ var index = []section{
|
| 169 | 169 |
containers: []ctrDesc{
|
| 170 | 170 |
{
|
| 171 | 171 |
name: "c1", |
| 172 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 172 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 173 | 173 |
}, |
| 174 | 174 |
}, |
| 175 | 175 |
}}, |
| ... | ... |
@@ -181,7 +180,7 @@ var index = []section{
|
| 181 | 181 |
containers: []ctrDesc{
|
| 182 | 182 |
{
|
| 183 | 183 |
name: "c1", |
| 184 |
- portMappings: nat.PortMap{"80/tcp": {{HostIP: "127.0.0.1", HostPort: "8080"}}},
|
|
| 184 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostIP: "127.0.0.1", HostPort: "8080"}}},
|
|
| 185 | 185 |
}, |
| 186 | 186 |
}, |
| 187 | 187 |
}}, |
| ... | ... |
@@ -33,7 +33,6 @@ import ( |
| 33 | 33 |
"github.com/docker/docker/integration/internal/testutils/networking" |
| 34 | 34 |
"github.com/docker/docker/testutil" |
| 35 | 35 |
"github.com/docker/docker/testutil/daemon" |
| 36 |
- "github.com/docker/go-connections/nat" |
|
| 37 | 36 |
containertypes "github.com/moby/moby/api/types/container" |
| 38 | 37 |
networktypes "github.com/moby/moby/api/types/network" |
| 39 | 38 |
swarmtypes "github.com/moby/moby/api/types/swarm" |
| ... | ... |
@@ -50,7 +49,7 @@ var ( |
| 50 | 50 |
|
| 51 | 51 |
type ctrDesc struct {
|
| 52 | 52 |
name string |
| 53 |
- portMappings nat.PortMap |
|
| 53 |
+ portMappings containertypes.PortMap |
|
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
type networkDesc struct {
|
| ... | ... |
@@ -79,7 +78,7 @@ var index = []section{
|
| 79 | 79 |
containers: []ctrDesc{
|
| 80 | 80 |
{
|
| 81 | 81 |
name: "c1", |
| 82 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 82 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 83 | 83 |
}, |
| 84 | 84 |
}, |
| 85 | 85 |
}}, |
| ... | ... |
@@ -92,7 +91,7 @@ var index = []section{
|
| 92 | 92 |
containers: []ctrDesc{
|
| 93 | 93 |
{
|
| 94 | 94 |
name: "c1", |
| 95 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 95 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 96 | 96 |
}, |
| 97 | 97 |
}, |
| 98 | 98 |
}}, |
| ... | ... |
@@ -105,7 +104,7 @@ var index = []section{
|
| 105 | 105 |
containers: []ctrDesc{
|
| 106 | 106 |
{
|
| 107 | 107 |
name: "c1", |
| 108 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 108 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 109 | 109 |
}, |
| 110 | 110 |
}, |
| 111 | 111 |
}}, |
| ... | ... |
@@ -139,7 +138,7 @@ var index = []section{
|
| 139 | 139 |
containers: []ctrDesc{
|
| 140 | 140 |
{
|
| 141 | 141 |
name: "c1", |
| 142 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 142 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 143 | 143 |
}, |
| 144 | 144 |
}, |
| 145 | 145 |
}}, |
| ... | ... |
@@ -152,7 +151,7 @@ var index = []section{
|
| 152 | 152 |
containers: []ctrDesc{
|
| 153 | 153 |
{
|
| 154 | 154 |
name: "c1", |
| 155 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 155 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 156 | 156 |
}, |
| 157 | 157 |
}, |
| 158 | 158 |
}}, |
| ... | ... |
@@ -165,7 +164,7 @@ var index = []section{
|
| 165 | 165 |
containers: []ctrDesc{
|
| 166 | 166 |
{
|
| 167 | 167 |
name: "c1", |
| 168 |
- portMappings: nat.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 168 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}},
|
|
| 169 | 169 |
}, |
| 170 | 170 |
}, |
| 171 | 171 |
}}, |
| ... | ... |
@@ -178,7 +177,7 @@ var index = []section{
|
| 178 | 178 |
containers: []ctrDesc{
|
| 179 | 179 |
{
|
| 180 | 180 |
name: "c1", |
| 181 |
- portMappings: nat.PortMap{"80/tcp": {{HostIP: "127.0.0.1", HostPort: "8080"}}},
|
|
| 181 |
+ portMappings: containertypes.PortMap{"80/tcp": {{HostIP: "127.0.0.1", HostPort: "8080"}}},
|
|
| 182 | 182 |
}, |
| 183 | 183 |
}, |
| 184 | 184 |
}}, |
| ... | ... |
@@ -25,7 +25,6 @@ import ( |
| 25 | 25 |
n "github.com/docker/docker/integration/network" |
| 26 | 26 |
"github.com/docker/docker/testutil" |
| 27 | 27 |
"github.com/docker/docker/testutil/daemon" |
| 28 |
- "github.com/docker/go-connections/nat" |
|
| 29 | 28 |
"github.com/google/go-cmp/cmp/cmpopts" |
| 30 | 29 |
containertypes "github.com/moby/moby/api/types/container" |
| 31 | 30 |
networktypes "github.com/moby/moby/api/types/network" |
| ... | ... |
@@ -389,7 +388,7 @@ func TestBridgeINCRouted(t *testing.T) {
|
| 389 | 389 |
container.WithNetworkMode(netName), |
| 390 | 390 |
container.WithName("ctr-"+gwMode),
|
| 391 | 391 |
container.WithExposedPorts("80/tcp"),
|
| 392 |
- container.WithPortMap(nat.PortMap{"80/tcp": {}}),
|
|
| 392 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {}}),
|
|
| 393 | 393 |
) |
| 394 | 394 |
t.Cleanup(func() {
|
| 395 | 395 |
c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -557,7 +556,7 @@ func TestAccessToPublishedPort(t *testing.T) {
|
| 557 | 557 |
container.WithNetworkMode(serverNetName), |
| 558 | 558 |
container.WithName("ctr-server"),
|
| 559 | 559 |
container.WithExposedPorts("80/tcp"),
|
| 560 |
- container.WithPortMap(nat.PortMap{"80/tcp": {nat.PortBinding{HostPort: "8080"}}}),
|
|
| 560 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {containertypes.PortBinding{HostPort: "8080"}}}),
|
|
| 561 | 561 |
container.WithCmd("httpd", "-f"),
|
| 562 | 562 |
) |
| 563 | 563 |
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -680,7 +679,7 @@ func TestInterNetworkDirectRouting(t *testing.T) {
|
| 680 | 680 |
container.WithNetworkMode(serverNetName), |
| 681 | 681 |
container.WithName("ctr-pub"),
|
| 682 | 682 |
container.WithExposedPorts("80/tcp"),
|
| 683 |
- container.WithPortMap(nat.PortMap{"80/tcp": {nat.PortBinding{HostPort: "8080"}}}),
|
|
| 683 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {containertypes.PortBinding{HostPort: "8080"}}}),
|
|
| 684 | 684 |
container.WithCmd("httpd", "-f"),
|
| 685 | 685 |
) |
| 686 | 686 |
defer c.ContainerRemove(ctx, ctrPubId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -1421,7 +1420,7 @@ func TestGatewaySelection(t *testing.T) {
|
| 1421 | 1421 |
container.WithName(ctrName), |
| 1422 | 1422 |
container.WithNetworkMode(netName4), |
| 1423 | 1423 |
container.WithExposedPorts("80"),
|
| 1424 |
- container.WithPortMap(nat.PortMap{"80": {{HostPort: "8080"}}}),
|
|
| 1424 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostPort: "8080"}}}),
|
|
| 1425 | 1425 |
container.WithCmd("httpd", "-f"),
|
| 1426 | 1426 |
) |
| 1427 | 1427 |
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -1870,7 +1869,7 @@ func TestDropInForwardChain(t *testing.T) {
|
| 1870 | 1870 |
ctrId := container.Run(ctx, t, c, |
| 1871 | 1871 |
container.WithNetworkMode(netName46), |
| 1872 | 1872 |
container.WithExposedPorts("80"),
|
| 1873 |
- container.WithPortMap(nat.PortMap{"80": {{HostPort: hostPort}}}),
|
|
| 1873 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostPort: hostPort}}}),
|
|
| 1874 | 1874 |
container.WithCmd("httpd", "-f"),
|
| 1875 | 1875 |
) |
| 1876 | 1876 |
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/integration/internal/container" |
| 10 | 10 |
"github.com/docker/docker/integration/internal/network" |
| 11 | 11 |
"github.com/docker/docker/testutil" |
| 12 |
- "github.com/docker/go-connections/nat" |
|
| 13 | 12 |
containertypes "github.com/moby/moby/api/types/container" |
| 14 | 13 |
"gotest.tools/v3/assert" |
| 15 | 14 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -97,7 +96,7 @@ func TestFlakyPortMappedHairpinWindows(t *testing.T) {
|
| 97 | 97 |
serverId := container.Run(ctx, t, c, |
| 98 | 98 |
container.WithNetworkMode(serverNetName), |
| 99 | 99 |
container.WithExposedPorts("80"),
|
| 100 |
- container.WithPortMap(nat.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 100 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 101 | 101 |
container.WithCmd("httpd", "-f"),
|
| 102 | 102 |
) |
| 103 | 103 |
defer c.ContainerRemove(ctx, serverId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -21,7 +21,6 @@ import ( |
| 21 | 21 |
"github.com/docker/docker/integration/internal/testutils/networking" |
| 22 | 22 |
"github.com/docker/docker/testutil" |
| 23 | 23 |
"github.com/docker/docker/testutil/daemon" |
| 24 |
- "github.com/docker/go-connections/nat" |
|
| 25 | 24 |
"github.com/moby/moby/api/pkg/stdcopy" |
| 26 | 25 |
containertypes "github.com/moby/moby/api/types/container" |
| 27 | 26 |
networktypes "github.com/moby/moby/api/types/network" |
| ... | ... |
@@ -69,12 +68,12 @@ func TestDisableNAT(t *testing.T) {
|
| 69 | 69 |
name string |
| 70 | 70 |
gwMode4 string |
| 71 | 71 |
gwMode6 string |
| 72 |
- expPortMap nat.PortMap |
|
| 72 |
+ expPortMap containertypes.PortMap |
|
| 73 | 73 |
}{
|
| 74 | 74 |
{
|
| 75 | 75 |
name: "defaults", |
| 76 |
- expPortMap: nat.PortMap{
|
|
| 77 |
- "80/tcp": []nat.PortBinding{
|
|
| 76 |
+ expPortMap: containertypes.PortMap{
|
|
| 77 |
+ "80/tcp": []containertypes.PortBinding{
|
|
| 78 | 78 |
{HostIP: "0.0.0.0", HostPort: "8080"},
|
| 79 | 79 |
{HostIP: "::", HostPort: "8080"},
|
| 80 | 80 |
}, |
| ... | ... |
@@ -84,8 +83,8 @@ func TestDisableNAT(t *testing.T) {
|
| 84 | 84 |
name: "nat4 routed6", |
| 85 | 85 |
gwMode4: "nat", |
| 86 | 86 |
gwMode6: "routed", |
| 87 |
- expPortMap: nat.PortMap{
|
|
| 88 |
- "80/tcp": []nat.PortBinding{
|
|
| 87 |
+ expPortMap: containertypes.PortMap{
|
|
| 88 |
+ "80/tcp": []containertypes.PortBinding{
|
|
| 89 | 89 |
{HostIP: "0.0.0.0", HostPort: "8080"},
|
| 90 | 90 |
{HostIP: "::", HostPort: ""},
|
| 91 | 91 |
}, |
| ... | ... |
@@ -95,8 +94,8 @@ func TestDisableNAT(t *testing.T) {
|
| 95 | 95 |
name: "nat6 routed4", |
| 96 | 96 |
gwMode4: "routed", |
| 97 | 97 |
gwMode6: "nat", |
| 98 |
- expPortMap: nat.PortMap{
|
|
| 99 |
- "80/tcp": []nat.PortBinding{
|
|
| 98 |
+ expPortMap: containertypes.PortMap{
|
|
| 99 |
+ "80/tcp": []containertypes.PortBinding{
|
|
| 100 | 100 |
{HostIP: "::", HostPort: "8080"},
|
| 101 | 101 |
{HostIP: "0.0.0.0", HostPort: ""},
|
| 102 | 102 |
}, |
| ... | ... |
@@ -125,7 +124,7 @@ func TestDisableNAT(t *testing.T) {
|
| 125 | 125 |
id := container.Run(ctx, t, c, |
| 126 | 126 |
container.WithNetworkMode(netName), |
| 127 | 127 |
container.WithExposedPorts("80/tcp"),
|
| 128 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8080"}}}),
|
|
| 128 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}}),
|
|
| 129 | 129 |
) |
| 130 | 130 |
defer c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
| 131 | 131 |
|
| ... | ... |
@@ -163,7 +162,7 @@ func TestPortMappedHairpinTCP(t *testing.T) {
|
| 163 | 163 |
serverId := container.Run(ctx, t, c, |
| 164 | 164 |
container.WithNetworkMode(serverNetName), |
| 165 | 165 |
container.WithExposedPorts("80"),
|
| 166 |
- container.WithPortMap(nat.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 166 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 167 | 167 |
container.WithCmd("httpd", "-f"),
|
| 168 | 168 |
) |
| 169 | 169 |
defer c.ContainerRemove(ctx, serverId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -210,7 +209,7 @@ func TestPortMappedHairpinUDP(t *testing.T) {
|
| 210 | 210 |
serverId := container.Run(ctx, t, c, |
| 211 | 211 |
container.WithNetworkMode(serverNetName), |
| 212 | 212 |
container.WithExposedPorts("54/udp"),
|
| 213 |
- container.WithPortMap(nat.PortMap{"54/udp": {{HostIP: "0.0.0.0"}}}),
|
|
| 213 |
+ container.WithPortMap(containertypes.PortMap{"54/udp": {{HostIP: "0.0.0.0"}}}),
|
|
| 214 | 214 |
container.WithCmd("/bin/sh", "-c", "echo 'foobar.internal 192.168.155.23' | dnsd -c - -p 54"),
|
| 215 | 215 |
) |
| 216 | 216 |
defer c.ContainerRemove(ctx, serverId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -252,7 +251,7 @@ func TestProxy4To6(t *testing.T) {
|
| 252 | 252 |
serverId := container.Run(ctx, t, c, |
| 253 | 253 |
container.WithNetworkMode(netName), |
| 254 | 254 |
container.WithExposedPorts("80"),
|
| 255 |
- container.WithPortMap(nat.PortMap{"80": {{HostIP: "::1"}}}),
|
|
| 255 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostIP: "::1"}}}),
|
|
| 256 | 256 |
container.WithCmd("httpd", "-f"),
|
| 257 | 257 |
) |
| 258 | 258 |
defer c.ContainerRemove(ctx, serverId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -376,7 +375,7 @@ func TestAccessPublishedPortFromHost(t *testing.T) {
|
| 376 | 376 |
serverID := container.Run(ctx, t, c, |
| 377 | 377 |
container.WithName(sanitizeCtrName(t.Name()+"-server")), |
| 378 | 378 |
container.WithExposedPorts("80/tcp"),
|
| 379 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: hostPort}}}),
|
|
| 379 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: hostPort}}}),
|
|
| 380 | 380 |
container.WithCmd("httpd", "-f"),
|
| 381 | 381 |
container.WithNetworkMode(bridgeName)) |
| 382 | 382 |
defer c.ContainerRemove(ctx, serverID, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -456,7 +455,7 @@ func TestAccessPublishedPortFromRemoteHost(t *testing.T) {
|
| 456 | 456 |
serverID := container.Run(ctx, t, c, |
| 457 | 457 |
container.WithName(sanitizeCtrName(t.Name()+"-server")), |
| 458 | 458 |
container.WithExposedPorts("80/tcp"),
|
| 459 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: hostPort}}}),
|
|
| 459 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: hostPort}}}),
|
|
| 460 | 460 |
container.WithCmd("httpd", "-f"),
|
| 461 | 461 |
container.WithNetworkMode(bridgeName)) |
| 462 | 462 |
defer c.ContainerRemove(ctx, serverID, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -554,7 +553,7 @@ func TestAccessPublishedPortFromCtr(t *testing.T) {
|
| 554 | 554 |
serverId := container.Run(ctx, t, c, |
| 555 | 555 |
container.WithNetworkMode(netName), |
| 556 | 556 |
container.WithExposedPorts("80"),
|
| 557 |
- container.WithPortMap(nat.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 557 |
+ container.WithPortMap(containertypes.PortMap{"80": {{HostIP: "0.0.0.0"}}}),
|
|
| 558 | 558 |
container.WithCmd("httpd", "-f"),
|
| 559 | 559 |
) |
| 560 | 560 |
defer c.ContainerRemove(ctx, serverId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -604,7 +603,7 @@ func TestRestartUserlandProxyUnder2MSL(t *testing.T) {
|
| 604 | 604 |
ctrOpts := []func(*container.TestContainerConfig){
|
| 605 | 605 |
container.WithName(ctrName), |
| 606 | 606 |
container.WithExposedPorts("80/tcp"),
|
| 607 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "1780"}}}),
|
|
| 607 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "1780"}}}),
|
|
| 608 | 608 |
container.WithCmd("httpd", "-f"),
|
| 609 | 609 |
container.WithNetworkMode(netName), |
| 610 | 610 |
} |
| ... | ... |
@@ -702,7 +701,7 @@ func TestDirectRoutingOpenPorts(t *testing.T) {
|
| 702 | 702 |
container.WithNetworkMode(netName), |
| 703 | 703 |
container.WithName("ctr-"+gwMode),
|
| 704 | 704 |
container.WithExposedPorts("80/tcp"),
|
| 705 |
- container.WithPortMap(nat.PortMap{"80/tcp": {}}),
|
|
| 705 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {}}),
|
|
| 706 | 706 |
) |
| 707 | 707 |
t.Cleanup(func() {
|
| 708 | 708 |
c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -972,7 +971,7 @@ func TestRoutedNonGateway(t *testing.T) {
|
| 972 | 972 |
ctrId := container.Run(ctx, t, c, |
| 973 | 973 |
container.WithCmd("httpd", "-f"),
|
| 974 | 974 |
container.WithExposedPorts("80/tcp"),
|
| 975 |
- container.WithPortMap(nat.PortMap{"80/tcp": {{HostPort: "8080"}}}),
|
|
| 975 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8080"}}}),
|
|
| 976 | 976 |
container.WithNetworkMode(natNetName), |
| 977 | 977 |
container.WithNetworkMode(routedNetName), |
| 978 | 978 |
container.WithEndpointSettings(natNetName, &networktypes.EndpointSettings{GwPriority: 1}),
|
| ... | ... |
@@ -1126,7 +1125,7 @@ func TestAccessPublishedPortFromAnotherNetwork(t *testing.T) {
|
| 1126 | 1126 |
container.WithName("server"),
|
| 1127 | 1127 |
container.WithCmd("nc", "-lp", "5000"),
|
| 1128 | 1128 |
container.WithExposedPorts("5000/tcp"),
|
| 1129 |
- container.WithPortMap(nat.PortMap{"5000/tcp": {{HostPort: "5000"}}}),
|
|
| 1129 |
+ container.WithPortMap(containertypes.PortMap{"5000/tcp": {{HostPort: "5000"}}}),
|
|
| 1130 | 1130 |
container.WithNetworkMode(servnet)) |
| 1131 | 1131 |
defer c.ContainerRemove(ctx, serverID, containertypes.RemoveOptions{Force: true})
|
| 1132 | 1132 |
|
| ... | ... |
@@ -1322,7 +1321,7 @@ func testDirectRemoteAccessOnExposedPort(t *testing.T, ctx context.Context, d *d |
| 1322 | 1322 |
container.WithName(sanitizeCtrName(t.Name()+"-server")), |
| 1323 | 1323 |
container.WithCmd("nc", "-lup", "5000"),
|
| 1324 | 1324 |
container.WithExposedPorts("5000/udp"),
|
| 1325 |
- container.WithPortMap(nat.PortMap{"5000/udp": {{HostPort: hostPort}}}),
|
|
| 1325 |
+ container.WithPortMap(containertypes.PortMap{"5000/udp": {{HostPort: hostPort}}}),
|
|
| 1326 | 1326 |
container.WithNetworkMode(bridgeName), |
| 1327 | 1327 |
container.WithEndpointSettings(bridgeName, &networktypes.EndpointSettings{
|
| 1328 | 1328 |
IPAddress: ctrIP.String(), |
| ... | ... |
@@ -1408,7 +1407,7 @@ func TestAccessPortPublishedOnLoopbackAddress(t *testing.T) {
|
| 1408 | 1408 |
container.WithCmd("nc", "-lup", "5000"),
|
| 1409 | 1409 |
container.WithExposedPorts("5000/udp"),
|
| 1410 | 1410 |
// This port is mapped on 127.0.0.2, so it should not be remotely accessible. |
| 1411 |
- container.WithPortMap(nat.PortMap{"5000/udp": {{HostIP: loIP, HostPort: hostPort}}}),
|
|
| 1411 |
+ container.WithPortMap(containertypes.PortMap{"5000/udp": {{HostIP: loIP, HostPort: hostPort}}}),
|
|
| 1412 | 1412 |
container.WithNetworkMode(bridgeName)) |
| 1413 | 1413 |
defer c.ContainerRemove(ctx, serverID, containertypes.RemoveOptions{Force: true})
|
| 1414 | 1414 |
|
| ... | ... |
@@ -1519,7 +1518,7 @@ func TestSkipRawRules(t *testing.T) {
|
| 1519 | 1519 |
|
| 1520 | 1520 |
ctrId := container.Run(ctx, t, c, |
| 1521 | 1521 |
container.WithExposedPorts("80/tcp"),
|
| 1522 |
- container.WithPortMap(nat.PortMap{"80/tcp": {
|
|
| 1522 |
+ container.WithPortMap(containertypes.PortMap{"80/tcp": {
|
|
| 1523 | 1523 |
{HostIP: "127.0.0.1", HostPort: "8080"},
|
| 1524 | 1524 |
{HostPort: "8081"},
|
| 1525 | 1525 |
}}), |
| ... | ... |
@@ -1551,10 +1550,10 @@ func TestMixAnyWithSpecificHostAddrs(t *testing.T) {
|
| 1551 | 1551 |
|
| 1552 | 1552 |
ctrId := container.Run(ctx, t, c, |
| 1553 | 1553 |
container.WithExposedPorts("80/"+proto, "81/"+proto, "82/"+proto),
|
| 1554 |
- container.WithPortMap(nat.PortMap{
|
|
| 1555 |
- nat.Port("81/" + proto): {{}},
|
|
| 1556 |
- nat.Port("82/" + proto): {{}},
|
|
| 1557 |
- nat.Port("80/" + proto): {{HostIP: "127.0.0.1"}},
|
|
| 1554 |
+ container.WithPortMap(containertypes.PortMap{
|
|
| 1555 |
+ containertypes.PortRangeProto("81/" + proto): {{}},
|
|
| 1556 |
+ containertypes.PortRangeProto("82/" + proto): {{}},
|
|
| 1557 |
+ containertypes.PortRangeProto("80/" + proto): {{HostIP: "127.0.0.1"}},
|
|
| 1558 | 1558 |
}), |
| 1559 | 1559 |
) |
| 1560 | 1560 |
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
| ... | ... |
@@ -15,7 +15,6 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/testutil/environment" |
| 16 | 16 |
"github.com/docker/docker/testutil/fakecontext" |
| 17 | 17 |
"github.com/docker/docker/testutil/request" |
| 18 |
- "github.com/docker/go-connections/nat" |
|
| 19 | 18 |
"github.com/moby/moby/api/types/build" |
| 20 | 19 |
containertypes "github.com/moby/moby/api/types/container" |
| 21 | 20 |
"github.com/moby/moby/api/types/image" |
| ... | ... |
@@ -164,9 +163,7 @@ COPY . /static`); err != nil {
|
| 164 | 164 |
// Find out the system assigned port |
| 165 | 165 |
i, err := c.ContainerInspect(context.Background(), b.ID) |
| 166 | 166 |
assert.NilError(t, err) |
| 167 |
- newP, err := nat.NewPort("tcp", "80")
|
|
| 168 |
- assert.NilError(t, err) |
|
| 169 |
- ports, exists := i.NetworkSettings.Ports[newP] |
|
| 167 |
+ ports, exists := i.NetworkSettings.Ports["80/tcp"] |
|
| 170 | 168 |
if !exists || len(ports) != 1 {
|
| 171 | 169 |
t.Fatalf("unable to find port 80/tcp for %s", container)
|
| 172 | 170 |
} |