0

I wanted to create a docker bench with basic setup and I use the basic code given at the Github link for Docker Benche Security. The code is as follows :

docker run --rm --net host --pid host --userns host --cap-add audit_control \
    -e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
    -v /etc:/etc:ro \
    -v /usr/bin/containerd:/usr/bin/containerd:ro \
    -v /usr/bin/runc:/usr/bin/runc:ro \
    -v /usr/lib/systemd:/usr/lib/systemd:ro \
    -v /var/lib:/var/lib:ro \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    --label docker_bench_security \
    docker/docker-bench-security

But I am getting an error saying

Error connecting to docker daemon (does docker ps work?)

Anybody has through solution for this with steps ?

Thank you very much in advance

Docker Version :

Client: Docker Engine - Community

  • Cloud integration: 1.0.7
  • Version: 20.10.2
  • API version: 1.41
  • Go version: go1.13.15
  • Git commit: 2291f61
  • Built: Mon Dec 28 16:14:16 2020
  • OS/Arch: windows/amd64
  • Context: default
  • Experimental: true

Server: Docker Engine - Community

  • Engine:
  • Version: 20.10.2
  • API version: 1.41 (minimum version 1.12)
  • Go version: go1.13.15
  • Git commit: 8891c58
  • Built: Mon Dec 28 16:15:28 2020
  • OS/Arch: linux/amd64
  • Experimental: false
  • containerd:
  • Version: 1.4.3
  • GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
  • runc:
  • Version: 1.0.0-rc92
  • GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
  • docker-init:
  • Version: 0.19.0
  • GitCommit: de40ad0

Linux Kernel Version : 3.1.6-340.x86_64

Error connecting to Docker Daemon

Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • 1
    So did you try what was suggested? What does `docker ps` give you? If it doesn't work, then you've got something wrong with your Docker setup. Maybe you just don't have your environment set to use a healthy Docker environment. You might try `docker context show`, especially if you have multiple Docker environments, and might have one of them powered down. That's often what leads to this problem. When faced with a problem in connection with a complex command like yours, it's best to fall back to simpler operations to figure out what's going on. – CryptoFool Mar 07 '21 at 07:04
  • Docker ps works for me. Because I use "docker run -itd to start a container first. Then I try to implement the code. So "docker ps" gives me the list of the running containers. – Tahmid Hossain Mar 07 '21 at 08:26
  • Glancing at the repository, it's just a couple of shell scripts; I'm not sure why it's packaged in Docker, given how much host access it requires. Can you run it with `sudo` directly on the host? (Are you trying to develop this, or just run a prepackaged application?) – David Maze Mar 07 '21 at 11:00
  • Yup. I tried working with `sudo`. It still did not work. I am just trying to run a prepackaged application. If I wanted to develop, I might not have faced this issue. – Tahmid Hossain Mar 08 '21 at 02:18

1 Answers1

-1

The problem occurs in the shell script docker-bench-security.sh that runs inside the container when you start it. Here's the block of code in question, which appears to be an early sanity check:

# Ensure we can connect to docker daemon
if ! docker ps -q >/dev/null 2>&1; then
  printf "Error connecting to docker daemon (does docker ps work?)\n"
  exit 1
fi

I'm on a Mac, and I get the same error doing simply:

docker run docker/docker-bench-security

so it has nothing to do with any of your parameters. I'm fairly new to Docker, and have never tried utilizing the docker command from inside a container, so I'm of no help here. I googled a bit, looking for an answer. I didn't find one. I found a few GitHub posts asking about the same problem, but no answers ever arrived on those threads:

https://github.com/docker/docker-bench-security/issues/197

https://github.com/docker/docker-bench-security/issues/123

Maybe someone will come along here and give you a better answer. I hope so. If not, there are some clues in these threads as to where you might want to look next for an answer.

CryptoFool
  • 21,719
  • 5
  • 26
  • 44