diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index 157e1bedc7..5ae7e8cc01 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -808,7 +808,7 @@ func parsePortOpts(publishOpts []string) ([]string, error) { params[opt[0]] = opt[1] } - optsList = append(optsList, fmt.Sprintf("%s:%s/%s", params["target"], params["published"], params["protocol"])) + optsList = append(optsList, fmt.Sprintf("%s:%s/%s", params["published"], params["target"], params["protocol"])) } return optsList, nil } diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 709119c5f7..46a4ba5192 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -872,3 +872,9 @@ func TestParseSystemPaths(t *testing.T) { assert.DeepEqual(t, readonlyPaths, tc.readonly) } } + +func TestParsePortOpts(t *testing.T) { + parsed, err := parsePortOpts([]string{"published=1500,target=200", "target=80,published=90"}) + assert.NilError(t, err) + assert.DeepEqual(t, []string{"1500:200/tcp", "90:80/tcp"}, parsed) +}