Permission Denied when trying to connect to Docker Daemon while running Jenkins pipeline on Macbook

I am trying to get Jenkins pipeline running on my macbook. I also have a docker instance running locally. Initially, I got a " docker command not found " message when starting Jenkins Job. I fixed the error by adding the symbolic link " ln -f -s / Applications / Docker.app / Contents / Resources / bin / * / usr / local / bin "

I also applied these two changes so that the jenkins user has access to the docker directory

  • chmod -R 777 / Users / myUserName / Library / Containers / com.docker.docker /
  • chmod -R 777 / Users / myUserName / Library / Containers / com.docker.helper /

I am getting below errors :

Received permission to refuse when trying to connect to Docker socket daemon in unix: ///var/run/docker.sock: Get http: //%2Fvar%2Frun%2Fdocker.sock/v1.27/containers/openjdk: 8 / json : dial unix / var / run / docker.sock: connect: reject allowed [Piping] sh [test] Run shell script + docker pull openjdk: 8 Warning: Could not get default replication endpoint from daemon (permission to try to connect to the Docker daemon socket in unix: ///var/run/docker.sock: Get http: //%2Fvar%2Frun%2Fdocker.sock/v1.27/info : type unix /var/run/docker.sock: connect : permission forbidden). Using the default system: https://index.docker.io/v1/    The granted permission was denied when trying to connect to the Docker daemon socket on unix: ///var/run/docker.sock: Message http: //%2Fvar%2Frun%2Fdocker.sock/v1.27/images/create? FromImage = openjdk & tag = 8 : dial unix / var / run / docker.sock: connect: deviate allowed [Piping]} [Piping] // node [Piping] End of piping ERROR: script returned exit code 1 Finished: FAILURE

+3


source to share


3 answers


This worked for me: docker run --rm -p 8080: 8080 -p 4040: 4040 -v / var / run / docker.sock: /var/run/docker.sock -v $ PWD / jenkins_home: / var / jenkins_home logimethods / jenkins



0


source


This is a docker permission issue. Add jenkins user to docker group as shown below:



usermod -aG docker ${USER}

+2


source


Is there a way to solve this problem, I ran into it last week, I solved it, but with docker-compose

this setting replicated to docker

, you can create a shared volume that points to a location docker.sock

in your host /var/run/docker.sock

before a location docker.sock

in your container /var/run/docker.sock

. Something like that:

version: '2'
services:
  jenkins:
    build:
      context: ./jenkins
    ports:
      - "8080:8080"
    expose:
      - "8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker
      - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose

  nginx:
    build:
      context: ./nginx
    container_name: "prueba"
    links:
      - jenkins
    ports:
      - "80:80"
    depends_on:
      - jenkins

      

To work well, you must grant user socket

sudo chown $USER:$USER /var/run/docker.sock

and group permissions docker

as stated by Innocent Anigbo .

+1


source







All Articles