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.

  • Elasticsearch Docker stop seems to ignore SIGKILL
  • Connecting IBM Containers (Dockers) to Watson IoT service instance
  • How do pass in DOCKER_OPTS into docker image running from Docker for Mac?
  • Docker gd module for PHP 7
  • cannot open RPM, skipping in Dockerfile
  • WordPress GUI on Kubernetes
  • 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 ?

  • Searching for the most optimal solution with Django, Docker, virtualenv and structure of files [closed]
  • Docker stopping after first line
  • Searching the Google Container Registry
  • What's Better for Many Containers: a Large Custom Base Image or Several Small Custom Images?
  • Syntax error when adding SSH key in GitLab CI
  • Docker: Reconnect new postgres container to existing Data container
  • 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’)

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.