Docker的安装
一. 环境准备
复制代码
1
2
3[root@hdzs-zhuji ~]# uname -r --查看系统内核 需要 3.10以上 4.18.0-348.7.1.el8_5.x86_64
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18[root@hdzs-zhuji ~]# uname -r ---查看系统版本 4.18.0-348.7.1.el8_5.x86_64 [root@hdzs-zhuji ~]# cat /etc/os-release NAME="CentOS Linux" VERSION="8" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" [root@hdzs-zhuji ~]#
二. 卸载旧版本
复制代码
1
2
3
4
5
6
7
8
9
10#卸载旧的版本 yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
三.需要的安装包
复制代码
1
2
3#下载需要的安装包 yum install -y yum-utils
四.设置镜像的仓库
复制代码
1
2
3
4
5
6
7
8
9#设置镜像仓库 但是这是国外的镜像仓库 下载会十分缓慢!! yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo --不用 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo --阿里云
五.安装Docker相关的
复制代码
1
2
3#安装 docker-ce ---社区版 ee 企业版 yum install docker-ce docker-ce-cli containerd.io
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32[root@hdzs-zhuji ~]# systemctl start docker ---启动docker [root@hdzs-zhuji ~]# docker version ---检查是否安装成功 Client: Docker Engine - Community Version: 20.10.18 API version: 1.41 Go version: go1.18.6 Git commit: b40c2f6 Built: Thu Sep 8 23:11:56 2022 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.18 API version: 1.41 (minimum version 1.12) Go version: go1.18.6 Git commit: e42327a Built: Thu Sep 8 23:10:04 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
六.测试
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28[root@hdzs-zhuji ~]# docker run hello-world --运行hello-world Unable to find image 'hello-world:latest' locally --首次说没找到 latest: Pulling from library/hello-world --下载 2db29710123e: Pull complete Digest: sha256:62af9efd515a25f84961b70f973a798d2eca956b1b2b026d0a4a63a3b0b6a3f2 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/
7. 查看镜像
刚才运行了 docker run hello-world 并且下载了相关镜像
复制代码
1
2
3
4
5
6
7##查看镜像 [root@hdzs-zhuji ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 12 months ago 13.3kB [root@hdzs-zhuji ~]#
8. 卸载Docker
复制代码
1
2
3
4
5###卸载Docker 资源 yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin rm -rf /var/lib/docker rm -rf /var/lib/containerd
9. 配置阿里云镜像加速器
-
地址 https://cr.console.aliyun.com/cn-beijing/instances/mirrors
-
配置使用
针对Docker客户端版本大于 1.10.0 的用户
可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
复制代码1
2
3
4
5
6
7
8
9
10
11sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://sexvedjf.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker ##完成配置
最后
以上就是含蓄冷风最近收集整理的关于Linux环境下的Docker安装的全部内容,更多相关Linux环境下内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复