Ubuntu20.4安装Docker

该博客详细介绍了如何在Ubuntu系统上安装Docker,包括更新系统、添加GPG密钥、设置国内镜像源、安装Docker以及优化设置,确保无需sudo权限即可运行Docker,并提供了验证安装和更换镜像仓库的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.

sudo apt-get update

 2.

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

 3.

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

4.

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable"

5.

sudo apt-get update

6.

sudo apt-get install docker-ce

输入:sudo docker info 查看安装信息

运行测试image hello-world 第一次运行 image 镜像不存在,自动从仓库下载hello-world镜像

sudo docker run hello-world

 7.更换镜像仓库为国内服务器

sudo gedit /etc/docker/daemon.json

 输入:以下内容 保存

{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com/"
  ]
}
systemctl daemon-reload
sudo systemctl restart docker

8.去除 docker sudo 前缀

sudo gpasswd -a ${USER} docker
sudo groupadd docker
sudo chmod a+rwx /var/run/docker.sock
sudo systemctl restart docker

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值