Docker教程第五章:安装-Docker引擎版本(ubuntu)
nanshan 2024-11-04 13:03 18 浏览 0 评论
准备
环境要求,需要一个64bit 的ubuntu系统,Docker Engine支持x86_64(或amd64)、armhf、arm64和s390x架构, 引擎支持overlay2, aufs and btrfs存储驱动,且docker引擎默认支持overlay2。支持ubuntu 版本如下:
- Ubuntu Impish 21.10
- Ubuntu Hirsute 21.04
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
执行如下命令卸载老版本docker引擎,/var/lib/docker/下存储了老的镜像、挂载卷、容器等文件如果不需要建议删除
sudo apt-get remove docker docker-engine docker.io containerd runc
安装方式一共三种:
- 仓库方式安装
- 安装包方式安装
- 脚本安装
采用仓库安装
安装工具
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
添加GPG秘钥
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gp
配置仓库源
$ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装引擎
查看指定版本
apt-cache madison docker-ce
最新版本安装
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
基于版本安装
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
验证安装
使用docker 运行hello-world镜像
banbohub@banbohub .~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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 apt-get update 根据相应说明进行升级,或者卸载后重新安装部署
采用安装包
如果无法使用ubuntu repository 进行安装,可以采用下载安装包(.deb)的形式进行安装
下载安装包
根据ubuntu版本,以及处理器架构(amd64, armhf, arm64, 活着 s390x)在https://download.docker.com/linux/ubuntu/dists/选择相应的docker 引擎版本下载
安装引擎
sudo dpkg -i /path/to/package.deb
验证安装
使用docker 运行hello-world镜像
banbohub@banbohub .~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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/D: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
更新镜像
需要重新下载新版本的安装包卸载,老版本后重新安装
脚本安装
Docker 官方为了简化安装流程,提供了一套安装脚本,Ubuntu 和 Debian 系统可 以使用这套脚本安装,但是不建议将便利脚本用于生产环境。该脚本的源代码是开源的,可以在GitHub上的docker安装存储库中找到。
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh ./get-docker.sh
省略sudo
创建 docker 用户组
sudo groupadd docker
将用户添加到 docker 组
sudo usermod -aG docker {your_username}
相关推荐
相关推荐
- Linux/Unix 系统中非常常用的命令
-
Linux/Unix系统中非常常用的命令,它们是进行文件操作、文本处理、权限管理等任务的基础。下面是对这些命令的简要说明:**文件操作类:*****`ls`(list):**列出目录内容,显...
- 教你如何在Linux中删除分区(CLI篇)
-
文接上篇,继续以Ubuntu系统为例。删除分区前,急得重要数据备份!备份!备份用命令操作分区,用的最多的莫过于fdisk了,几乎所有的Linux发行版都默认带有fdisk。首先要知道的是,你想删除的分...
- 敲完就让你提桶跑路的Linux命令(敲完就让你提桶跑路的linux命令是什么)
-
不谨慎可能就会让你提桶的Linux命令!!!删除文件rm-rf该命令是删除文件或文件夹等最快的方式之一。删除后的内容很难恢复,如果删除系统文件可能会导致系统崩坏。>rm-rf/#强制...
- Log文件可以删除吗(taxukeylog文件可以删除吗)
-
Log文件(日志文件)是否可以删除取决于具体场景和文件类型。以下是详细分析和建议:一、哪些Log文件可以删除?非关键应用日志用户级应用日志:如浏览器缓存日志、游戏临时日志等,通常不影响系统运行,可定期...
- Linux 删除空目录(linux直接删除目录)
-
rmdir命令用来删除空目录。当目录不再被使用时,或者磁盘空间已到达使用限定值,就需要删除失去使用价值的目录。利用rmdir命令可以从一个目录中删除一个或多个空的子目录。该命令从一个目录中删除一个或...
- 在 Windows 11 或 10 上删除、创建和格式化分区
-
在Windows11或10上删除、创建和格式化分区假设您的现有电脑使用的是传统硬盘,但现在您想再添加一个硬盘或SSD。当然,后者将用于启动操作系统,而前者将作为纯数据存储。在成功将操作系统...
- 如何使用 Apt Clean 命令清除 APT 缓存?
-
APT(AdvancedPackageTool)是Debian系Linux发行版的包管理工具,用于处理软件包的安装、升级和依赖管理。在使用apt命令(如aptinstall、apt...
- Linux 磁盘空间不够用?5 招快速清理文件,释放 10GB 空间不是梦!
-
刚收到服务器警告:磁盘空间不足90%!装软件提示Nospaceleftondevice!连日志都写不进去,系统卡到崩溃?别慌!今天教你5个超实用的磁盘清理大招,从临时文件到无用软件一键搞定...
- Linux清空日志方法(linux怎么清理日志)
-
方法1:使用>重定向>/path/to/logfile或(需要权限时):sudosh-c'>/var/log/logfile'方法2:使用trun...
- 如何在Eclipse中搭建Zabbix源码的调试和开发环境
-
Zabbix是一款非常优秀的企业级软件,被设计用于对数万台服务器、虚拟机和网络设备的数百万个监控项进行实时监控。Zabbix是开放源码和免费的,这就意味着当出现bug时,我们可以很方便地通过调试源码来...
- Linux操作系统之常用命令(linux操作系统之常用命令有哪些)
-
Linux操作系统一、常用命令1.系统(1)系统信息arch显示机器的处理器架构uname-m显示机器的处理器架构uname-r显示正在使用的内核版本dmidecode-q显示硬件系...
- 理解linux内核的vmlinuz和initrd(linux内核原理及分析)
-
Originaladdress:http://www.chenjunlu.com/2010/11/understanding-of-vmlinuz-initrd-and-system-map/1....
- Linux纯干货知识总结|面试专用(linux面试宝典)
-
学习Linux的重要性相信不用我多说大家也明白,以下是小编总结的常用Linux基础知识以及面试常问的Linux命令,希望能帮助大家更规范地理解和使用~绝对路径和相对路径绝对路径以正斜杠开始完整的文件的...
- Linux基础知识之启动流程分析(简述linux启动流程)
-
Linux系统启动原理:1.poweron开机。2.开机自检:电脑开机后首先加载BIOS(BasicInput/OutputSystem基本输入输出系统)。BIOS程序首先检查计算机能否满足运...
- Java程序员必备——Linux的面试常见问题及面试题!你知道多少?
-
一.常用命令1.编辑相关①.awkNF:字段总数NR:第几行数据FS:分隔字符②.sed-n-i直接修改4a:在第四行后添加4i:在第四行前插入1,5csting:用sting替换1到5行...
你 发表评论:
欢迎- 一周热门
- 最近发表
- 标签列表
-
- linux 查询端口号 (58)
- docker映射容器目录到宿主机 (66)
- 杀端口 (60)
- yum更换阿里源 (62)
- internet explorer 增强的安全配置已启用 (65)
- linux自动挂载 (56)
- 禁用selinux (55)
- sysv-rc-conf (69)
- ubuntu防火墙状态查看 (64)
- windows server 2022激活密钥 (56)
- 无法与服务器建立安全连接是什么意思 (74)
- 443/80端口被占用怎么解决 (56)
- ping无法访问目标主机怎么解决 (58)
- fdatasync (59)
- 405 not allowed (56)
- 免备案虚拟主机zxhost (55)
- linux根据pid查看进程 (60)
- dhcp工具 (62)
- mysql 1045 (57)
- 宝塔远程工具 (56)
- ssh服务器拒绝了密码 请再试一次 (56)
- ubuntu卸载docker (56)
- linux查看nginx状态 (63)
- tomcat 乱码 (76)
- 2008r2激活序列号 (65)