Let's break this down.
First, if you want to see a list of the dangling volumes you can simply run:
docker volume ls -qf dangling=true
docker volume ls lists the volumes and -qf means list only the ids and filter on dangling=true.
To delete these volumes we'll pass them in to the docker volume rm function which takes a volume id or list of ids. The final command is:
docker volume rm $(docker volume ls -qf dangling=true)