Reputation: 333
I am trying to remove all stopped containers to free up some space on an AWS Ubuntu server that I am using. Docker documentation says to use docker rm $(docker ps -a -q)
: https://docs.docker.com/engine/reference/commandline/rm/#remove-all-stopped-containers
However, I am getting the error below:
"docker rm" requires at least 1 argument.
See 'docker rm --help'.
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
Any suggestions?
Adding sudo in front doesn't help. I am able to remove individual containers using docker rm 343e43ac4e86
, but I don't want to spend a lot of time trying to figure out which containers are from older releases and removing them one by one.
Upvotes: 2
Views: 1415
Reputation: 169
Please use these command in your terminal:
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker network prune -f
docker rmi -f $(docker images --filter dangling=true -qa)
docker volume rm $(docker volume ls --filter dangling=true -q)
Upvotes: 0
Reputation: 96
I think you could also try docker ps -aq | xargs docker rm
if the substitution doesn't work out.
Upvotes: 3