I'm trying to get Docker networks list and filter it by name using Docker HTTP API 1.24.
For some reason, filters are extremly poorly documented, the very single example in whole Docker documentation is this one (and it works):
GET /networks?filters={"type":{"custom":true}} HTTP/1.1
What is confusing, this lonely example seems to contradict official Docker notation for filters:
map[string][]string
which is discussed here: https://stackoverflow.com/a/28055631/4486909
API spec didn't do much help either:
Query parameters:
filters - JSON encoded network list filter. The filter value is one of:
driver=<driver-name> Matches a network’s driver.
id=<network-id> Matches all or part of a network id.
label=<key> or label=<key>=<value> of a network label.
name=<network-name> Matches all or part of a network name.
type=["custom"|"builtin"] Filters networks by type.
http://docs.master.dockerproject.org/engine/reference/api/docker_remote_api_v1.24/#/list-networks
These ones don't filter our anything, returning full list of netwroks.
curl -vg -X GET "v1.24/networks" --data-urlencode 'filters={"name":["MyNetwork"]}'
curl -vg -X GET "v1.24/networks" --data-urlencode 'filters={"name":["MyNetwork":true]}'
curl -vg -X GET "v1.24/networks" --data-urlencode 'filters={"name":"MyNetwork"}'
What am I doing wrong? Many thanks.