1、卸载旧版本
apt-get remove docker docker-engine docker.io containerd runc
2、安装前提依赖
apt update
apt-get install ca-certificates curl gnupg lsb-release
3、安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4、写入软件源信息
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5、安装新版本
apt-get install docker-ce docker-ce-cli containerd.io
6、用户组相关(这步比较重要,否则后续查看docker版本的时候会有报错提示并且也无法启动docker: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.24/version": dial unix /var/run/docker.sock: connect: permission denied)
sudo groupadd docker #添加docker用户组
sudo gpasswd -a XXX docker #将当前用户添加至docker用户组,其中XXX为用户名
newgrp docker #更新docker用户组
7、启动docker
systemctl start docker
docker version(查看docker版本)
8、安装必要工具
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
9、配置 docker
# 添加 docker 配置 /etc/docker/daemon.json(需要在目录下自行添加daemon.json)
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"registry-mirrors": ["https://hub-mirror.c.163.com","https://gxeo3yz7.mirror.aliyuncs.com"]
}
10、重启docker
service docker restart
标签:get,步骤,用户组,ce,apt,ubuntu,docker From: https://www.cnblogs.com/starnc/p/16591833.html