Docker – Cannot connect to the Docker Daemon to rm containers
Playing with ELK and docker, I needed to restart every services.
docker ps told me that I haven’t any containers up.
docker run -it --rm [...] --name es elasticsearch ->
Error response from daemon. The name "es" is already use by container [...]
So I try to remove all container :
docker ps -a -q | xargs docker rm ->
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
The container is not up but still here.
Of course I can simply change my container’s name but it’s not right. That mean I have container running. Even if I restart my server.
Any idea ?
2 Solutions collect form web for “Docker – Cannot connect to the Docker Daemon to rm containers”
When you stop your container it’s not getting removed by default, unless you’re providing
--rm flag. So, it could be so, like you have started and stopped some container with
es name before and it’s stopped now. But it’s not possible to create a new container with the existing name, even if the existing one is not running. Try to use a
-a flag to show all containers you have as:
docker ps -a
If you have some with the name
es, just remove it manually with:
docker rm es
You also able to provide
-f flag, to force removing the
es container even if it’s running.
docker rm es should do the trick. Furthermore, if you want to remove a running container, you can add the -f parameter(docker rm -f ‘container_name’)