Jenkins中构建(Build)Docker镜像时出现permission denied

问题描述

Jenkins中构建(Build)Docker镜像时出现permission denied,jenkins日志如下

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/build?buildargs=%7B%22envType%22%3A%22--spring.profiles.active%3Dtest%22%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=swzfw4zq2xwq9bmwlzuibujcj&shmsize=0&t=172.18.207.211%3A5000%2Fzxcx%2Fbff-admin-service%3A1.0.1.13-test&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied
time="2020-10-10T13:59:03+08:00" level=error msg="Can't close tar writer: io: read/write on closed pipe"
Build step 'Execute shell' marked build as failure
Finished: FAILURE

问题分析

通过Jenkins日志我们可以看到访问这个目录时/var/run/docker.sock:出现权限错误

解决方案

把这个目录的权限打开

chmod -R 777 /var/run/docker.sock

你可能感兴趣的:(【运维】,运维)