When using cURL
for some queries to the Docker API
, it might be a bit tricky to pass some complex structures. Let's say, getting a list of images allows using filters as a query parameter, which have to be a JSON
representation of map[string][]string
(about the maps in Go
you can find more here).
Here is how to achieve this:
curl --unix-socket /var/run/docker.sock \
-XGET "http:/v1.29/images/json" \
-G \
--data-urlencode 'filters={"reference":{"yourpreciousregistry.com/path/to/image": true}, "dangling":{"true": true}}'
Here the -G
flag is used to specify that the data in the --data-urlencode
parameter will be used in an HTTP GET
request instead of the POST
request that otherwise would be used. The data will be appended to the URL with a ?
separator.