Running a host docker command inside a denkins docker container

I have a docker container in which jenkins work. I want another container running inside this container, so outside this container.

I tried to start my jenkins controller using

docker run -v /var/run/docker.sock:/var/run/docker.sock  -v $(which docker):/bin/docker

(As written here: https://jpetazzo.imtqy.com/2015/09/03/do-not-use-docker-in-docker-for-ci/ )

But when inside my container I try to run the Docker command, I have a typical message

 FATA[0000] Get http://%2Fvar%2Frun%2Fdocker.sock/v1.18/containers/json: dial unix /var/run/docker.sock: 
connect: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS? 

And there is no need to run the docker command inside this container.

I tried with and without --privileged = true, it still doesn't work.

If you have any ideas!

+4
source share
2 answers

.

( ). : (1) docker.sock (2) docker .

(1): @yclian, jenkins docker.

. sudo docker run ... sudo , , Jenkins root- , .

(2) -v $(which docker):/bin/docker . MacOS. which docker /usr/local/bin/docker/, , docker . jenkins

docker run -p 8080:8080 -p 50000:50000 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /Users/matthaeus/.jenkins_home:/var/jenkins_home -t -i jenkins

, docker engine , , (docker exec -t -i container-id /bin/bash apt-get install docker-engine), Dockerfile.

, sudo docker build -t my-image ., -.

+1

, /var/run/docker.sock . , jenkins docker, .

, jenkins, Jenkins.

0

Source: https://habr.com/ru/post/1613534/


All Articles