docker 踩坑集錦

zigzag99發表於2020-10-19

問題 1:docker permission denied

問題記錄:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/json: dial unix /var/run/docker.sock: connect: permission denied

解決方案:

#1. 新增 docker 使用者組
sudo groupadd docker 

#2. 將登陸使用者加入到docker使用者組中
sudo gpasswd -a $USER docker 

#3. 更新使用者組
newgrp docker 

問題 2:docker timeout

問題記錄:

問題記錄: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

解決方案:

sudo vim /etc/docker/daemon.json # 新增以下內容

{
  "registry-mirrors": ["https://registry.docker-cn.com","https://nrbewqda.mirror.aliyuncs.com","https://dmmxhzvq.mirror.aliyuncs.com"]
}

systemctl restart docker # 重啟docker ××執行完後有些配置會消失,重新配置

相關文章