操作系统:centos7.9
内核版本:6.3.2-1.el7.elrepo.x86_64
IP地址:192.168.0.245
1、linux内核版本依赖
kernel version >= 3.8
- 可以使用如下命令查看
uname -a | awk '{split($3, arr, "-"); print arr[1]}'
- 如果已安装过Docker, 需要移除老版本的Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
- 添加Docker repository yum源
# 国内源, 速度更快, 推荐
sudo yum-config-manager \
--add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
# 官方源, 服务器在国外, 安装速度慢
# $ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
开始安装Docker Engine
sudo yum makecache fast
sudo yum install docker-ce docker-ce-cli containerd.io
开启Docker
sudo systemctl enable docker
sudo systemctl start docker
验证是否安装成功
sudo docker run hello-world
# 如果出现"Hello from Docker.", 则代表运行成功
- 如果在每次运行docker命令是, 在前面不添加sudo, 可以执行如下命令:
sudo usermod -aG docker $USER
- 如果嫌上面安装步骤麻烦, 可以运行如下脚本来安装
- 不能在生产系统中使用
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
sudo systemctl enable docker
sudo systemctl start docker
sudo groupadd docker
sudo usermod -aG docker $USER
[root@bogon ~]# docker info
Client: Docker Engine - Community
Version: 24.0.2
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.5
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.18.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 24.0.2
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc version: v1.1.7-0-g860f061
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 6.3.2-1.el7.elrepo.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.89GiB
Name: bogon
ID: edc7efff-0eb4-46dd-9820-c57dab677f36
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
[root@bogon ~]# docker -v
Docker version 24.0.2, build cb74dfc
[root@bogon ~]#