1.开始安装
由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:
sudo apt-get remove docker docker-engine docker-ce docker.io
更新apt包索引:
sudo apt-get update
更新apt包索引时,下载很慢,所以更换镜像源文件
备份ubantu默认的源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
可参考博客:https://blog.csdn.net/weixin_41762173/article/details/79480832
安装以下包以使apt可以通过HTTPS使用存储库(repository):
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
在此步遇到问题:
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
解决问题:
参考博客:https://blog.csdn.net/weixin_42116341/article/details/100019319
输入以下命令删除锁定文件
sudo rm /var/lib/dpkg/lock-frontend sudo rm /var/lib/dpkg/lock
添加Docker官方的GPG密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
使用下面的命令来设置stable存储库:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
再更新一下apt包索引:
sudo apt-get update
安装最新版本的Docker CE:
sudo apt-get install -y docker-ce
出现同样的问题:
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
解决问题同上输入命令删除锁定文件
2.验证docker
查看docker服务是否启动:
systemctl status docker
若未启动,则启动docker服务:
sudo systemctl start docker
经典的hello world:(使用的Xshell6)
sudo docker run hello-world
参考文章:
1.https://blog.csdn.net/jinking01/article/details/82490688
作者:舟华520
出处:https://www.cnblogs.com/xfzh193/
本文以学习,分享,研究交流为主,欢迎转载,请标明作者出处!