Ubuntu安装docker

(在Ubuntu18.04&&Ubuntu20.04上安装成功)

具体步骤

1.打开终端

使用命令: cat /proc/version 

使用命令: uname -a 

使用命令: lsb_release -a 

确定ubuntu的版本

2.为了输入方便,提前打开管理员用户

sudo su

3.使用上述命令若进入/home目录,需要定向回初始目录

cd

4.检查更新

apt-get update

5.检查以下软件是否安装(为了防止在安装docker时遗漏重要文件)

apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

6.添加签名

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add

7.验证签名的指纹

apt-key fingerprint 0EBFCD88

8. 确定仓库路径(Ubuntu18.04:bionic && Ubunt20.04: focal)

lsb_release -cs

9.添加仓库

Ubunt18.04默认

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

Ubunt20.04默认

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

第8步有差别

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu 仓库路径 stable"

10.检查更新

apt-get update

11.安装docker-ce(社区版)

apt-get install -y docker-ce docker-ce-cli containerd.io

12.检查docker能否正常工作

docker run hello-world

13.将docker添加进用户文件夹(以后不需要sudo就可以运行)

usermod -aG docker $USER

到这里,docker的安装已经完成

最后可以试着拉取一个镜像

docker pull redis

ps:如果拉取速度太慢可以尝试按以下步骤更改

(1)打开文件

vi /etc/docker/daemon.json

(2)写入

{ "registry-mirrors": ["https://registy.docker-cn.com"] }

(3)重启docker

systemctl restart docker

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值