mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
fix: add missing portmap when needed (#1183)
This commit is contained in:
parent
a1bdd268c1
commit
04db93c770
2 changed files with 22 additions and 19 deletions
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
dockercontainer "github.com/docker/docker/api/types/container"
|
dockercontainer "github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/go-connections/nat"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContainer returns a new Container instance instantiated with the
|
// NewContainer returns a new Container instance instantiated with the
|
||||||
|
|
@ -208,8 +209,6 @@ func (c Container) PreUpdateTimeout() int {
|
||||||
return minutes
|
return minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// StopSignal returns the custom stop signal (if any) that is encoded in the
|
// StopSignal returns the custom stop signal (if any) that is encoded in the
|
||||||
// container's metadata. If the container has not specified a custom stop
|
// container's metadata. If the container has not specified a custom stop
|
||||||
// signal, the empty string "" is returned.
|
// signal, the empty string "" is returned.
|
||||||
|
|
@ -319,8 +318,10 @@ func (c Container) VerifyConfiguration() error {
|
||||||
return errorInvalidConfig
|
return errorInvalidConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Instead of returning an error here, we just create an empty map
|
||||||
|
// This should allow for updating containers where the exposed ports are missing
|
||||||
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil {
|
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil {
|
||||||
return errorNoExposedPorts
|
containerConfig.ExposedPorts = make(map[nat.Port]struct{})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,13 @@ var _ = Describe("the container", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
When("verifying a container with port bindings, but no exposed ports", func() {
|
When("verifying a container with port bindings, but no exposed ports", func() {
|
||||||
It("should return an error", func() {
|
It("should make the config compatible with updating", func() {
|
||||||
c := mockContainerWithPortBindings("80/tcp")
|
c := mockContainerWithPortBindings("80/tcp")
|
||||||
c.containerInfo.Config.ExposedPorts = nil
|
c.containerInfo.Config.ExposedPorts = nil
|
||||||
err := c.VerifyConfiguration()
|
Expect(c.VerifyConfiguration()).To(Succeed())
|
||||||
Expect(err).To(Equal(errorNoExposedPorts))
|
|
||||||
|
Expect(c.containerInfo.Config.ExposedPorts).ToNot(BeNil())
|
||||||
|
Expect(c.containerInfo.Config.ExposedPorts).To(BeEmpty())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
When("verifying a container with port bindings and exposed ports is non-nil", func() {
|
When("verifying a container with port bindings and exposed ports is non-nil", func() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue