Skip to content

Commit 8671a5e

Browse files
authored
Merge pull request #4493 from akerouanton/create-default-endpoint-settings
Create default EndpointSettings if no --network provided
2 parents d4aca90 + f1048e1 commit 8671a5e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

cli/command/container/opts.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,20 @@ func parseNetworkOpts(copts *containerOptions) (map[string]*networktypes.Endpoin
732732
hasUserDefined, hasNonUserDefined bool
733733
)
734734

735+
if len(copts.netMode.Value()) == 0 {
736+
n := opts.NetworkAttachmentOpts{
737+
Target: "default",
738+
}
739+
if err := applyContainerOptions(&n, copts); err != nil {
740+
return nil, err
741+
}
742+
ep, err := parseNetworkAttachmentOpt(n)
743+
if err != nil {
744+
return nil, err
745+
}
746+
endpoints["default"] = ep
747+
}
748+
735749
for i, n := range copts.netMode.Value() {
736750
n := n
737751
if container.NetworkMode(n.Target).IsUserDefined() {
@@ -792,7 +806,7 @@ func applyContainerOptions(n *opts.NetworkAttachmentOpts, copts *containerOption
792806
n.Aliases = make([]string, copts.aliases.Len())
793807
copy(n.Aliases, copts.aliases.GetAll())
794808
}
795-
if copts.links.Len() > 0 {
809+
if n.Target != "default" && copts.links.Len() > 0 {
796810
n.Links = make([]string, copts.links.Len())
797811
copy(n.Links, copts.links.GetAll())
798812
}

0 commit comments

Comments
 (0)