diff --git a/container/container.go b/container/container.go index 48ba72e..c49da33 100644 --- a/container/container.go +++ b/container/container.go @@ -136,7 +136,12 @@ func (c Container) runtimeConfig() *dockercontainer.Config { config.Volumes = structMapSubtract(config.Volumes, imageConfig.Volumes) - config.ExposedPorts = structMapPortSubtract(config.ExposedPorts, imageConfig.ExposedPorts) + // subtract ports exposed in image from container + for k, _ := range config.ExposedPorts { + if _, ok := imageConfig.ExposedPorts[k]; ok { + delete(config.ExposedPorts, k) + } + } for p := range c.containerInfo.HostConfig.PortBindings { config.ExposedPorts[p] = struct{}{} } diff --git a/container/util.go b/container/util.go index 184b491..8947c82 100644 --- a/container/util.go +++ b/container/util.go @@ -1,7 +1,6 @@ package container import ( - "github.com/docker/go-connections/nat" ) func sliceEqual(s1, s2 []string) bool { @@ -67,14 +66,3 @@ func structMapSubtract(m1, m2 map[string]struct{}) map[string]struct{} { return m } -func structMapPortSubtract(m1, m2 map[nat.Port]struct{}) map[nat.Port]struct{} { - m := map[nat.Port]struct{}{} - - for k1, v1 := range m1 { - if _, ok := m2[k1]; !ok { - m[k1] = v1 - } - } - - return m -} diff --git a/container/util_test.go b/container/util_test.go index c4d5ca7..9ed551d 100644 --- a/container/util_test.go +++ b/container/util_test.go @@ -63,3 +63,4 @@ func TestStructMapSubtract(t *testing.T) { assert.Equal(t, map[string]struct{}{"a": x, "b": x, "c": x}, m1) assert.Equal(t, map[string]struct{}{"a": x, "c": x}, m2) } +