Manage docker images from "docker jenkins conainer"?


I found a similar themes on the internet, but I did not get to do it.
Tell me where and what I am doing wrong.

I have a container with jenkins, from it I want to rebuild/recreate the container on the host machine.

I have read this article and another
My docker compose looks so.

version: '2'
      image: "mongo"
      container_name: "ca_mongo"
        - "27017:27017"
        - /home/jdev/docker-storage/mongo:/data/db
      image: "jenkins"
      container_name: "ca_jenkins"
        - "18080:8080"
        - "50000:50000"
        - /home/jdev/docker-storage/jenkins:/var/jenkins_home
        - /var/run/docker.sock:/var/run/docker.sock

I’m starting docker compose, than go with the root user to the jenkins container.

> docker exec -u 0 -it ca_jenkins bash

I install there docker.

And I expect with the “docker ps” command to see my running containers on the host machine. But get the following error.

root@3dccb3a60c2c:/# docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.18/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

May be a problem in versions?
On the host machine: Docker version 1.12.3, build 6b644ec
On the Jenkins-container: Docker version 1.6.2, build 7c8fca2

Maybe someone has already done similar and suggest ready-made solution? I would be grateful for tips or decision. !!


Instead of using Docker in Docker ,It is better to use only a docker client inside a container and mount the /var/run/docker.sock so you can run command on the docker daemon installed on the host itself.

there is a docker image on the hub for this

and also you might useful this step by step tutorial I did for jenkins and docker pipeline