Docker + maven build problem — unix://localhost:80: Permission denied

烟雨浮华發表於2024-05-31

使用docker-maven-plugin進行構建映象報錯如下:

com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied

解決方案 :

Add the docker group if it doesn’t already exist:

sudo groupadd docker  #增加docker組,如果存在,跳過

Add the connected user “$USER” to the docker group. Change the user name to match your preferred user if you do not want to use your current user:

sudo usermod -aG docker jenkins  #將jenkins使用者新增到docker組

Provide the /var/run/docker.sock socket and /var/run/docker directory the proper permissions to make it work:

sudo chown root:docker /var/run/docker.sock  #docker.sock的許可權修改
sudo chown -R root:docker /var/run/docker

If the above commands do not resolve your issue try to run the below command from root:
chmod 666 /var/run/docker.sock

相關文章