Jenkins中構建(Build)Docker映象時出現permission denied

艾特老司機發表於2020-10-10

問題描述

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

相關文章