PublishAllPorts: don't crash with nil PortBindings

Introduced by commit 85b260f ("PublishAllPorts: create
port mappings for exposed ports").

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray
2025-11-29 16:01:47 +00:00
parent 2faf258d4d
commit 7517464283
3 changed files with 27 additions and 0 deletions

View File

@@ -42,6 +42,9 @@ func decodeCreateRequest(src io.Reader) (container.CreateRequest, error) {
if w.HostConfig == nil {
w.HostConfig = &container.HostConfig{}
}
if w.HostConfig.PortBindings == nil {
w.HostConfig.PortBindings = make(network.PortMap)
}
// Make sure NetworkMode has an acceptable value. We do this to ensure
// backwards compatible API behavior.
//