关闭防火墙以及 selinux (必选)
__set_config() {firewall-cmd --statesystemctl stop firewalld.servicesystemctl disable firewalld.servicesetenforce 0sed -i 's,^SELINUX=.*$,SELINUX=disabled,' /etc/selinux/config}__set_config
优化内核参数 (可选)
- 下面备用链接
bash -c "$(curl -sS https://gitlab.biz.kuaicdn.cn/shell/centos/-/raw/main/kernel/kernel_init.sh)"
# 备用链接#bash -c "$(curl -sS https://gitee.com/lwmacct/web-vscode-shell/raw/main/workspace/shell/centos/kernel/sysctl.sh)"
设置阿里云 CentOS 镜像源 (可选,建议设置)
__set_mirrors() {curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repocurl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.reposed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repoyum clean allyum makecache fastyum install -y sudo}__set_mirrors
CentoOS7 系 安装 Docker (正文)
__install_docker() {yum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.reposed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repoyum makecache fastyum -y install docker-ceusermod -aG docker rootmkdir -p /etc/dockercat >/etc/docker/daemon.json <<EOF{"registry-mirrors": ["https://bn4ll166.mirror.aliyuncs.com"],"data-root": "/data/docker-root","dns": ["223.5.5.5","119.29.29.29"],"bip": "172.31.255.254/16","storage-driver": "overlay2","storage-opts": ["overlay2.override_kernel_check=true"],"userland-proxy": false,"log-driver": "json-file","log-opts": {"max-size": "100m","max-file": "1"},"exec-opts": ["native.cgroupdriver=systemd"],"live-restore": true}EOFsystemctl daemon-reloadsystemctl enable dockersystemctl restart docker}__install_docker
安装 docker-compose
使用 Docker 释放安装
- 由于部分网络从Github 下载安装较慢,
- 运行命令, 使用 Docker 释放安装
- 按需选择安装版本, 版本区别尚未观察, 详情查阅 https://github.com/docker/compose/releases
docker run --privileged --rm -v /usr/local/bin/:/dest registry.cn-hangzhou.aliyuncs.com/lwmacct/file:1657436749-docker-compose-v2.6.1
docker run --privileged --rm -v /usr/local/bin/:/dest registry.cn-hangzhou.aliyuncs.com/lwmacct/file:1649397829-docker-compose-v2.4.1
从 Github 安装
网络好的话推荐从 github 安装 官方教程>>
