Manage docker images from "docker jenkins conainer"?

Hi,

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 https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
My docker compose looks so.

version: '2'
services:
    mongo-db:
      image: "mongo"
      container_name: "ca_mongo"
      ports:
        - "27017:27017"
      volumes:
        - /home/jdev/docker-storage/mongo:/data/db
    ci:
      image: "jenkins"
      container_name: "ca_jenkins"
      ports:
        - "18080:8080"
        - "50000:50000"
      volumes:
        - /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. !!

Thanks!

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
https://hub.docker.com/_/docker/

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