ubuntu版本 22.04 (lsb_release -a)
1. 更新软件包引用,并安装依赖包
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
2. 安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
3. 添加apt软件源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
4. 更新并安装docker-ce
sudo apt-get -y update
sudo apt-get -y install docker-ce
可指定版本安装
1)查看版本
apt-cache madison docker-ce ==》 docker-ce | 5:20.10.17~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
或者 apt list -a docker-ce ==》 docker-ce/jammy,now 5:20.10.17~3-0~ubuntu-jammy amd64 [已安装]
2)指定版本号
sudo apt-get -y install docker-ce=[5:20.10.17~3-0~ubuntu-jammy]
5. 验证安装
docker version
=======================================================================
安装中遇到的问题
1. lsb_release-cs未找到命令
各种自身的原因,还重装了一次ubuntu,今天才发现原来是-cs前面少了个空格
2. 正在等待缓存锁:无法获得锁 /var/lib/dpkg/lock-frontend。锁正由进程 5843(unattended-upgr)持有
kill 5843 进程杀不死,最后只好重启ubuntu了,没有什么是重启解决不了的
3. Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
可以忽略
4. W: https://download.docker.com/linux/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
可以忽略