# Docker inside Jenkins container

**URL:** <https://forums.docker.com/t/docker-inside-jenkins-container/3583>\
**Category:** General\
**Created:** [September 26, 2015, 9:34pm UTC](https://forums.docker.com/t/docker-inside-jenkins-container/3583 "2015-09-26T21:34:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmarquesantos](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nmarquesantos](https://forums.docker.com/u/nmarquesantos)\
**Post date:** [September 26, 2015, 9:34pm UTC](https://forums.docker.com/t/docker-inside-jenkins-container/3583/1 "2015-09-26T21:34:46Z")

</div>

Hi there.

I have been searching for a solution but without any luck.

I want to use a Jenkins container for a series of docker-related jobs. For that, I am trying to mount the docker socket into my container.

I successfully manage to start my jenkins container with the following params:

> docker run --name jenkins --privileged=true -t -i --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/bin/docker -p 8080:8080 jenkins

the docker command is detected successfully. However, when I try a simple command inside the container like

> docker version  
> Client:  
> Version: 1.8.2  
> API version: 1.20  
> Go version: go1.4.2  
> Git commit: 0a8c2e3  
> Built: Thu Sep 10 19:19:00 UTC 2015  
> OS/Arch: linux/amd64  
> Get http:///var/run/docker.sock/v1.20/version: dial unix /var/run/docker.sock: permission denied.

- Are you trying to connect to a TLS-enabled daemon without TLS?
- Is your docker daemon up and running?

What am I missing? I have added the jenkins user to the docker group.

---

<div class="post-metadata">

**Author:** ![svendowideit](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/svendowideit/32/119_2.png) [@svendowideit](https://forums.docker.com/u/svendowideit)\
**Post date:** [September 27, 2015, 1:18am UTC](https://forums.docker.com/t/docker-inside-jenkins-container/3583/2 "2015-09-27T01:18:15Z")

</div>

I’m doing something similar - and its working for me

because I want the Jenkins container to work with any docker.sock, I’m using a script like  
[https://github.com/SvenDowideit/docs-automation/blob/master/jenkins/setup-docker-and-start-jenkins.sh](https://github.com/SvenDowideit/docs-automation/blob/master/jenkins/setup-docker-and-start-jenkins.sh) to create the docker group in the jenkins container, and then add the jenkins user to it.

perhaps the container’s docker group does not match the host’s one?

or maybe you have SELinux, and need to give the container SELinux permission to access the HOST’s socket.

---

<div class="post-metadata">

**Author:** ![nmarquesantos](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nmarquesantos](https://forums.docker.com/u/nmarquesantos)\
**Post date:** [September 27, 2015, 9:06am UTC](https://forums.docker.com/t/docker-inside-jenkins-container/3583/3 "2015-09-27T09:06:05Z")

</div>

Thanks sven, that almost did the trick.

I just needed to add

> RUN chmod +x

after the copy command and all worked fine.
