docker 安装和错误解决方案
安装
x64 架构
- install docker
- switch mirror
- docker desktop
- docker run -d -p 80:80 docker/getting-started
arm64 架构(树莓派 4b)
How To Install Docker and Docker-Compose On Raspberry Pi
升级 docker-compose
How to upgrade docker-compose to latest version
错误解决方案
- Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- curl docker-compose permission denied
#进入超级用户 sudo -i # 切换为普通用户 su ubuntu # 退出当前用户 exit
- 设置非root账号不用sudo直接执行docker命令
# 创建名为docker的组,如果之前已经有该组就会报错,可以忽略这个错误 sudo groupadd docker # 将当前用户加入组 docker sudo gpasswd -a ${USER} docker # 重启 docker 服务(生产环境请慎用) sudo systemctl restart docker # 添加访问和执行权限 sudo chmod a+rw /var/run/docker.sock
- docker 开机自启动
sudo systemctl enable docker