Docker安装(Centos/Ubuntu/UOS)

Centos

centos7.4及以上

关闭防火墙

关闭selinux

安装所需的依赖

shell 复制代码
yum install -y yum-utils device-mapper-persistent-data lvm2

添加centos7和docker的yum源

shell 复制代码
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-altarch-7.repo(arm)
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

建立缓存

shell 复制代码
yum makecache fast

安装docker-20.10.8

shell 复制代码
yum -y install  docker-ce-20.10.8-3.el7 docker-ce-cli-20.10.8-3.el7

配置

创建配置目录,编辑配置文件

shell 复制代码
mkdir /etc/docker
vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://*******.mirror.aliyuncs.com"],
  "insecure-registries":["xxxx.xxxx.xxxx:5000"],
  "data-root": "/data/docker",
  "log-driver":"json-file",
  "log-opts": {"max-size":"1024m", "max-file":"2"}
}

registry-mirrors :配置镜像加速

insecure-registries:忽略ssl证书验证(地址修改为需要的地址)

data-root:配置docker存储目录

log-opts: 配置容器日志的大小限制和数量

启动docker

加载配置,开机自启,启动docker

shell 复制代码
systemctl daemon-reload
systemctl enable docker
systemctl start docker

Ubuntu

关闭防火墙

关闭selinux

添加docker源

shell 复制代码
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

查看有哪些版本

shell 复制代码
apt-cache madison docker-ce

安装docker-20.10.18

shell 复制代码
apt-get -y install docker-ce=5:20.10.18~3-0~ubuntu-jammy docker-ce-cli=5:20.10.18~3-0~ubuntu-jammy

配置

修改配置文件

shell 复制代码
vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://*******.mirror.aliyuncs.com"],
  "insecure-registries":["xxxx.xxxx.xxxx:5000"],
  "data-root": "/data/docker",
  "log-driver":"json-file",
  "log-opts": {"max-size":"1024m", "max-file":"2"}
}

registry-mirrors :配置镜像加速

insecure-registries:忽略ssl证书验证(地址修改为需要的地址)

data-root:配置docker存储目录

log-opts: 配置容器日志的大小限制和数量

启动docker

加载配置,开机自启,重启docker

shell 复制代码
systemctl daemon-reload
systemctl enable docker
systemctl restart docker

UOS

关闭防火墙

关闭selinux

添加docker源

shell 复制代码
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian buster stable" >> /etc/apt/sources.list

查看有哪些版本

shell 复制代码
apt-cache madison docker-ce

安装docker-20.10.18

shell 复制代码
apt-get -y install docker-ce=5:20.10.18~3-0~debian-buster docker-ce-cli=5:20.10.18~3-0~debian-buster

配置

修改配置文件

shell 复制代码
vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://*******.mirror.aliyuncs.com"],
  "insecure-registries":["xxxx.xxxx.xxxx:5000"],
  "data-root": "/data/docker",
  "log-driver":"json-file",
  "log-opts": {"max-size":"1024m", "max-file":"2"}
}

registry-mirrors :配置镜像加速

insecure-registries:忽略ssl证书验证(地址修改为需要的地址)

data-root:配置docker存储目录

log-opts: 配置容器日志的大小限制和数量

启动docker

加载配置,开机自启,重启docker

shell 复制代码
systemctl daemon-reload
systemctl enable docker
systemctl restart docker
相关推荐
墨倾许19 小时前
《Windows 11 + Docker:极简DVWA靶场搭建全记录》—— 附详细排错指南与最终解决方案
windows·笔记·网络安全·docker·容器·靶场
岚天start19 小时前
解决方案—K8S集群的日志按天并按照命名空间分类定时同步到日志服务器
服务器·docker·kubernetes·shell·日志备份
微学AI19 小时前
内网穿透的应用-摆脱局域网!Stable Diffusion3.5 结合cpolar使用更方便
docker·stable diffusion·内网穿透
梁萌20 小时前
linux中使用docker安装MySQL
linux·运维·docker·容器·mysql安装
晨晖220 小时前
docker打包,启动java程序
java·docker·容器
文言一心20 小时前
SenseVoice 离线部署指南(Xinference Docker v1.12)
运维·docker·ai·容器
AIchiNiurou20 小时前
mermaid install for free docker
运维·docker·容器
❀͜͡傀儡师20 小时前
根据docker服务保存日志脚本,时间可选版本
运维·docker·容器
搬砖的小码农_Sky20 小时前
Ubuntu Desktop Linux 文件和文件夹操作命令详解
linux·运维·ubuntu
探模之翼20 小时前
DeepSeek-OCR 部署、配置解析与测试完整指南
docker·大模型·ocr