ubuntu20.04 LTS安装docker的方法步骤
作者:进步号无人货运飞船 发布时间:2022-07-10 07:00:15
零:卸载旧版本
Docker 的旧版本被称为 docker,docker.io 或 docker-engine 。如果已安装,请卸载它们:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
当前称为 Docker Engine-Community 软件包 docker-ce 。
一:设置仓库
在新主机上首次安装 Docker Engine-Community 之前,需要设置 Docker 仓库。之后,您可以从仓库安装和更新 Docker 。
更新 apt 包索引。
$ sudo apt-get update
安装 apt 依赖包,用于通过HTTPS来获取仓库:
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
添加 Docker 的官方 GPG 密钥:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥。
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
使用以下指令设置稳定版仓库
注意:目前 20.04 还没有国内 docker 源,暂时用 18.04 版本。
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
bionic \
stable"
二:安装 Docker Engine-Community
更新 apt 包索引。
$ sudo apt-get update
安装最新版本的 Docker Engine-Community 和 containerd
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
三:测试
输入
$ sudo docker run hello-world
如果docker和你问好——或者说出现类似以下输出
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
就说明安装完事了。
四:免sudo运行&镜像加速
免sudo
参考如下方法将用户添加到docke组
$ sudo usermod -aG docker [你的用户名]
重启docker
$ sudo systemctl restart docker
(然而我的机器上发生了很诡异的事——我重启docker服务后依然不能以普通用户启动docker。重启机器后才能免sudo运行。)
docker镜像加速
我用了阿里云的免费加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
后续设置按照阿里云网页内提示即可,不再赘述。
五:参考链接
-Windows10 安装 WSL2 Ubuntu20.04 并设置 docker 环境
-Ubuntu Docker 安装
来源:https://www.cnblogs.com/songxi/p/12788249.html


猜你喜欢
- 不同的站点对安全级别的要求不同,康盛创想(Comsenz)推出的Discuz!系统允许站点管理者,通过自定义配置文件中的 config.in
- 在IIS5,多IP下共存,IIS为192.168.0.1,apache为192.168.0.2c:\Inetpub\Adminscripts
- 今天安装mongodb后发现apache无法启动命令行 services.msc 打开服务在服务里启动Apache2a服务,报错误码1网上查
- 拉取镜像docker pull nacos/nacos-server查看镜像docker images启动容器中的nacosdocker r
- 企业网站设计的8条要素:设计一个网站,应该考虑下列九条基本因素,这些因素对网站的成功与否有着重要影响。九项网站设计成功要素:整体布局,有价值
- 1.新建用户wwweee000[root@localhost ~]# useradd wwweee000[root@localhost ~]
- 首先下载VMware安装包:双击安装:点击:“uninstall”安装,这个过程需要一些时间点击“Next”选择典型或者自定义安装这里我选择
- 尽管功能服务器概念的提出可以追溯到十几年前,可是功能服务器的产品是这两三年才火起来的,因为它是为了满足用户的特殊需求而定制的专用服务器。说到
- 1.更新您的source ,我们之前提过 更新source不代表升级 ,仍需要经过编译的动作。 编译source 1./usr/src#ma
- 本篇文章详细介绍了linux软连接和硬链接,废话不多说,接着往下看把。一 链接文件Linux链接分两种,一种被称为硬链接(Hard Link
- 如何制作高质量的链接?也就是链接的权重问题。链接建设分外部链接和内部链接两个部分,本文将围绕这两个方面对SEO链接进行简单分析,让大家明白,
- 如果用户开启了列表分页,分页显示了2页以上分页,却发现除了第一页以为的其他页都出现“还没有任何项目”的提示。则可能是你存储过程有问题,如下图
- 1.检查并安装pssh,yum list pssh2.因为没有配置免秘钥登陆,pssh命令执行失败。[root@bogon ]# pssh
- Serv-U是一个FTP服务器程序(用户可以从www.serv-u.com网站下载),能够运行于Windows 95/98/2000/Me/
- 北京时间3月3日消息,据国外媒体报道,微软首席执行官史蒂夫·鲍尔默星期二在一个搜索引擎会议上表示,微软认为,Google为了获得互联网搜索广
- 拒绝游泳的鱼:各位安徽及各地的互联网朋友们,大家下午好。老k一直在做非常公益的这些本地站长的交流,所以鱼特别支持来和大家聊一下。其实很多的技
- 搜狐近日公布了2009年度财务报告,总收入达5.152亿美元,年增长率达20%,其中子公司畅游所运营的游戏业务收入为2.676亿美元,超过母
- 网赚常见英文信范例网赚中,有时难免遇到问题需要跟外国网赚公司交流,这就要求你会写英文信。 以下列出了几个最常见的问题及范例信写法,希望对网赚
- 我们经常收到发布商的来信询问收入到底是按展示计算还是按点击计算,为什么帐户报告中广告已经展示了几千次却没有任何收入。答案是您的收入如何计算取
- StartLogic 公司为客户提供强有力的支持和极具竞争力的虚拟主机服务。 他们提供一系列的产品,包括共享虚拟主机(包括Windows、U