diff --git a/components/engine/api/server/router/network/network.go b/components/engine/api/server/router/network/network.go index 8688c3ed1f..f940ae0a26 100644 --- a/components/engine/api/server/router/network/network.go +++ b/components/engine/api/server/router/network/network.go @@ -31,7 +31,8 @@ func (r *networkRouter) initRoutes() { r.routes = []router.Route{ // GET router.NewGetRoute("/networks", r.getNetworksList), - router.NewGetRoute("/networks/{id:.*}", r.getNetwork), + router.NewGetRoute("/networks/", r.getNetworksList), + router.NewGetRoute("/networks/{id:.+}", r.getNetwork), // POST router.NewPostRoute("/networks/create", r.postNetworkCreate), router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect), diff --git a/components/engine/daemon/network.go b/components/engine/daemon/network.go index 57547993ed..65631bc71a 100644 --- a/components/engine/daemon/network.go +++ b/components/engine/daemon/network.go @@ -59,6 +59,7 @@ func (daemon *Daemon) GetNetworkByID(partialID string) (libnetwork.Network, erro } // GetNetworkByName function returns a network for a given network name. +// If no network name is given, the default network is returned. func (daemon *Daemon) GetNetworkByName(name string) (libnetwork.Network, error) { c := daemon.netController if c == nil { diff --git a/components/engine/docs/reference/api/docker_remote_api.md b/components/engine/docs/reference/api/docker_remote_api.md index 6053db96d6..33441f7857 100644 --- a/components/engine/docs/reference/api/docker_remote_api.md +++ b/components/engine/docs/reference/api/docker_remote_api.md @@ -125,6 +125,9 @@ This section lists each version from latest to oldest. Each listing includes a * `POST /containers/create` now takes a `Mounts` field in `HostConfig` which replaces `Binds` and `Volumes`. *note*: `Binds` and `Volumes` are still available but are exclusive with `Mounts` * `POST /build` now performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. Note that this change is _unversioned_ and applied to all API versions. * `POST /build` accepts `cachefrom` parameter to specify images used for build cache. +* `GET /networks/` endpoint now correctly returns a list of *all* networks, + instead of the default network if a trailing slash is provided, but no `name` + or `id`. ### v1.24 API changes