Merge pull request #6516 from zhangguanzhang/master

fix api fails with 'strconv.ParseUint: parsing "tcp": invalid syntax'
This commit is contained in:
OpenShift Merge Robot 2020-06-11 10:27:59 -04:00 committed by GitHub
commit f1b6840382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -465,8 +465,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
ports := make(nat.PortSet)
for p := range inspect.HostConfig.PortBindings {
splitp := strings.Split(p, "/")
port, err := nat.NewPort(splitp[0], splitp[1])
splitp := strings.SplitN(p, "/", 2)
if len(splitp) != 2 {
return nil, errors.Errorf("PORT/PROTOCOL Format required for %q", p)
}
port, err := nat.NewPort(splitp[1], splitp[0])
if err != nil {
return nil, err
}