Ubuntu安装Docker

测试环境: Ubuntu desktop 16、Ubuntu Server 20

安装Docker

由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:

sudo apt-get remove docker docker-engine docker-ce docker.io

更新apt包索引:

sudo apt-get update

安装以下包以使apt可以通过HTTPS使用存储库(repository):

sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

添加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

验证docker

查看docker服务是否启动:

systemctl status docker

若未启动,则启动docker服务:

sudo systemctl start docker

经典的hello world:

sudo docker run hello-world

作者:buildings
声明 :对于转载分享我是没有意见的,出于对博客园社区和作者的尊重请保留原文地址哈。
致读者 :坚持写博客不容易,写高质量博客更难,我也在不断的学习和进步,希望和所有同路人一道用技术来改变生活。觉得有点用就点个赞哈。

原文地址:https://www.cnblogs.com/luengmingbiao/p/14750395.html