Cannot remove all containers in a row
I started yesterday to use Docker and I unfortunately created a ton of containers.
Now I want to delete all of them. It would be really boring to delete them one by one because I have like 45 containers with no tag.
I found that I should use do delete all of them with one command something like :
sudo docker rm $(docker ps -q)
But when I try to use this command, it doesn’t work.
This is my output :
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/containers/json: dial unix /var/run/docker.sock: connect: permission denied "docker kill" requires at least 1 argument(s). See 'docker kill --help'. Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] Kill one or more running containers
I understand that $(docker ps -q) doesn’t work well because there is a permission denied problem. But I don’t really know how I can solve this situation.
Any help ?
Thanks a lot !
One Solution collect form web for “Cannot remove all containers in a row”
I believe your docker daemon is not running. You can check it with
sudo /etc/init.d/docker status
If it’s running, maybe it is configured not to listen on
/var/run/docker.sock. You can check in
/etc/default/docker if any
-H option is specified in
Related topic: after installing Docker you are prompted to add your user to the docker group. Run the command shown and restart your session to have the change taken into account, so you won’t need to run commands with