I’m running a DooD (Docker outside of Docker) scenario on Docker for Mac.
This means I have a Docker container (specifically a Jenkins agent/slave) with installed Docker engine inside the container.
The container is started with docker-compose with the compose setup below:
agent:
image: softwarecraftsmen/jenkins-agent
restart: always
environment:
- JENKINS_AGENT_PASSWORD
ports:
- "22:22"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# http://stackoverflow.com/questions/26021181/not-enough-entropy-to-support-dev-random-in-docker-containers-running-in-boot2d
- /dev/urandom:/dev/random
Running a bash inside the agent container using docker exec -ti jenkins_agent_1 bash -c "docker ps"
is giving a list of running containers on the host (my mac). The command is successfully executed as root as the docker host’s socket is mapped to the container using a volume.
I have a user jenkins in this container that was added to the groups jenkins, docker, and even root. The groups command is confirming that.
root@aa926508b08a:/# groups jenkins
jenkins : jenkins root docker
However when becoming user jenkins the docker ps command is failing:
jenkins@aa926508b08a:/$ docker ps -a
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
As I have followed the suggested setup I have to assume that the problem is somehow related to mapping the host’s socket to the container. Though I may be wrong and something essential is missing.
My docker version inside the client is:
docker -v
Docker version 1.12.1
My docker host (mac) is
docker -v
Docker version 1.12.1, build 6f9534c, experimental