Docker Docker Engine API Making a cURL request with passing some complex structure

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any Docker Question?