1 配置主机名
[root@localhost ~]# hostnamectl set-hostname docker && bash
2 关闭防火墙
[root@docker ~]# systemctl stop firewalld && systemctl disable firewalld
3 关闭selinux
[root@docker ~]# setenforce 0 //临时关闭
[root@docker ~]# set -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
//永久关闭
[root@docker ~]# reboot //重启
4
[rootdocker ~]# yum install -y wget net-tools nfs-utils lrzsz gcc gcc-c++make cmake 1ibxm12-devel openssl-devel curl curl-devel unzip sudo ntp libaio-develmcurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server socat
安装基础软件包
5 安装docker-ce
5.1 配置阿里云的yum源
[root@docker ~]# sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
5.2 安装docker-ce
[root@docker ~]# yum install docker-ce -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
安装成功截图
5.3 启动docker 设置开机自启
[root@docker ~]# systemctl start docker && systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
5.4 查看docker是否运行成功
[root@docker ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2024-07-19 12:58:09 CST; 1min 15s ago
Docs: https://docs.docker.com
Main PID: 2898 (dockerd)
CGroup: /system.slice/docker.service
└─2898 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
7月 19 12:58:09 docker systemd[1]: Starting Docker Application Container Engine...
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.669109643+08:00" level=info msg="St... up"
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.733615148+08:00" level=info msg="Lo...rt."
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.865534337+08:00" level=info msg="Lo...ne."
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.887282877+08:00" level=info msg="Do....1.4
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.887417370+08:00" level=info msg="Da...ion"
7月 19 12:58:09 docker dockerd[2898]: time="2024-07-19T12:58:09.929560511+08:00" level=info msg="AP...ock"
7月 19 12:58:09 docker systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
可以看到docker启动成功
//附加 查看docker 版本
[root@docker ~]# docker version
Client: Docker Engine - Community
Version: 26.1.4
API version: 1.45
Go version: go1.21.11
Git commit: 5650f9b
Built: Wed Jun 5 11:32:04 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.1.4
API version: 1.45 (minimum version 1.24)
Go version: go1.21.11
Git commit: de5c9cf
Built: Wed Jun 5 11:31:02 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.33
GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0