Issue
I have Docker Desktop installed on my Windows 10 notebook on a debian distro. The problem I have is when I want to run docker inside a container with jenkins.
I create the jenkins container with a docker-compose:
version: '2.4'
services:
jenkins:
image: jenkins/jenkins
user: root
privileged: true
container_name: jenkins
restart: unless-stopped
ports:
- 8080:8080
- 8443:8443
- 50000:50000
group_add:
- 1000
volumes:
- jenkins_home:/var/jenkins_home
- /c/Users/user/.docker/config.json:/root/.docker/config.json:ro
- /c/Users/user/.docker/machine/certs:/root/.docker:ro
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/bin/docker
environment:
- JENKINS_OPTS="--prefix=/jenkins"
When I run the container, I get in by running:
>docker exec -it -u root jenkins sh
>docker
>sh: docker: Permission denied
and won't let me do anything else. I can't build images in pipelines either.
I read everything I found in google but nothing helped me. Some guides say to create add the jenkins user to the docker group, but that does not help me because I am running jenkins in a container.
I exposed the address tcp://0.0.0.0:2375
and it didn't work.
I created an intermediate container with "alpine/socat" but it didn't work either.
How can I do to run docker commands inside the jenkins container, being in WSL?
Thanks.
Solution
Finally, I found the solution in this link: https://github.com/docker/for-win/issues/1480#issuecomment-355671606
For those who come looking for the solution for the same problem, you just have to install the docker client and that's it.
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-17.09.1-ce.tgz | sudo tar -C /usr/local/bin -xz --strip=1 docker/docker
In my case, it was not necessary to put export DOCKER_HOST=tcp://localhost:2375
because Docker Desktop already exposes that port. If I added it, I got the error Cannot connect to the Docker daemon at tcp://localhost: 2375. Is the docker daemon running?
, so I didn't put it.
Answered By - Loandoer Answer Checked By - Robin (WPSolving Admin)