$ [sudo] docker ps -q -a | xargs [sudo] docker rm-q prints only the container IDs, -a prints all containers.
Notice that it uses xargs to issue a remove container command for each container ID.
$ [sudo] docker rmi $([sudo] docker images | grep "^<none>" | awk '{print $3}')awk must use a single quote or the curly brackets will be interpreted by the shell.