CentOS一键安装docker脚本

CentOS安装Docker一键脚本

在CentOS上安装Docker是许多项目中常见的任务之一。为了简化这个过程,你可以使用下面的一键脚本。

bash 复制代码
#!/bin/bash

# 卸载旧版本(如果有)
sudo yum remove -y docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

# 安装依赖包
sudo yum install -y yum-utils \
      device-mapper-persistent-data \
      lvm2

# 设置Docker稳定仓库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 安装Docker引擎
sudo yum install -y docker-ce docker-ce-cli containerd.io

# 启动Docker服务
sudo systemctl start docker

# 设置Docker开机自启
sudo systemctl enable docker

# 验证安装是否成功
sudo docker run hello-world

运行:

java 复制代码
chmod +x install_docker.sh
./install_docker.sh
相关推荐
Anthony_2313 小时前
Linux 从基础操作到故障排查
linux·运维·服务器·网络·nginx·ubuntu·centos
2601_961194021 天前
化学教资科三真题答案
linux·windows·ubuntu·pdf·centos·gnu
tang7451639622 天前
Huawei Cloud EulerOS 2.0(x8664)安装OpenJDK 2120260323
linux·运维·centos
xiep14383335102 天前
CentOS 7.9 安装 TigerVNC
linux·运维·centos
老杨聊技术2 天前
CentOS 7 安装 Docker 完整版教程
linux·docker·centos
norsd2 天前
CentOS Rocky Linux 设置 ip
linux·tcp/ip·centos
键盘上的猫头鹰3 天前
【Linux 基础教程(一)】概述、安装与网络配置:VMware + CentOS + NAT + XShell 远程连接
linux·网络·centos
隔窗听雨眠3 天前
CentOS Stream 9 服务器 Docker 部署 KaiwuDB 实战
服务器·docker·centos
木卫二号Coding3 天前
第八十五篇-CentOS-7 + Tesla V100 环境下 Docker 容器内编译部署 Qwen3.6-27B-MTP 大模型实战指南
linux·docker·centos
流觞 无依3 天前
CentOS 7 系统中 systemd 组件的 CVE-2022-2526 漏洞修复
linux·运维·centos