通过YUM工具安装
寻找合适的docker版本
1 查看Linux内核版本
- 我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上
[root@localhost ~]
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]
Linux localhost.localdomain 3.10.0-1160.el7.x86_64
安装docker-engine
1 yum包管理器
1.1 升级最新版本
[root@localhost ~]
1.2 安装需要的软件包
[root@localhost ~]
1.3 设置yum源
[root@localhost ~]
已加载插件:fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
2 docker安装
2.1 版本
[root@localhost ~]
已加载插件:fastestmirror
可安装的软件包
* updates: mirrors.cn99.com
Loading mirror speeds from cached hostfile
* extras: mirrors.cn99.com
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7
2.1 安装
[root@localhost ~]
2.2 启动
[root@localhost ~]
[root@localhost ~]
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
2.3 验证
[root@localhost ~]
Client:
Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:15:20 2018
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.1-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:54 2018
OS/Arch: linux/amd64
Experimental: false
通过官方脚本安装
下载安装脚本
[root@docker01 src]
[root@docker01 src]
[root@docker01 src]
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: https://docs.docker.com/go/attack-surface/
================================================================================
[root@docker01 src]
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com
[root@docker01 src]
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@docker01 src]
[root@docker01 src]
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2022-05-28 21:47:49 CST; 6s ago
Docs: https://docs.docker.com
Main PID: 1393 (dockerd)
Tasks: 7
Memory: 34.7M
CGroup: /system.slice/docker.service
└─1393 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
5月 28 21:47:47 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:47.783608279+08:00" level=info msg="ccRes...=grpc
5月 28 21:47:47 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:47.783615129+08:00" level=info msg="Clien...=grpc
5月 28 21:47:47 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:47.824634346+08:00" level=info msg="Loadi...art."
5月 28 21:47:48 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:48.729357337+08:00" level=info msg="Defau...ress"
5月 28 21:47:48 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:48.864526334+08:00" level=info msg="Firew...ning"
5月 28 21:47:48 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:48.972378763+08:00" level=info msg="Loadi...one."
5月 28 21:47:49 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:48.999444294+08:00" level=info msg="Docke...10.16
5月 28 21:47:49 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:48.999562103+08:00" level=info msg="Daemo...tion"
5月 28 21:47:49 docker01.zangh dockerd[1393]: time="2022-05-28T21:47:49.043155492+08:00" level=info msg="API l...sock"
5月 28 21:47:49 docker01.zangh systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@docker01 src]
Docker version 20.10.16, build aa7e414
[root@docker01 src]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES