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
相关推荐
想唱rap1 小时前
MYSQL在ubuntu下的安装
linux·数据库·mysql·ubuntu
java_logo1 小时前
QWEN3 企业级 Docker 容器化部署指南
运维·docker·容器·qwen3部署·qwen3部署文档·qwen3部署教程·qwen3部署方案
taihexuelang2 小时前
大模型部署
人工智能·docker·容器
zbguolei2 小时前
Debian提示:“用户名” 不是 sudoers 文件
linux·服务器·debian
oMcLin2 小时前
如何在 Debian 11 上通过配置 LVM 和 RAID 结合,提升大规模存储系统的性能与冗余性
运维·debian
zhyf1192 小时前
零刻AI Max395(Ubuntu 24.04)AMD 显卡监控工具(amdgpu_top)部署手册
linux·运维·ubuntu
释怀不想释怀3 小时前
Docker(项目部署)
运维·docker·容器
计算机小手3 小时前
Docker 部署 weserv-images:打造非侵入式图片处理中间件
图像处理·经验分享·docker·中间件
敬往事一杯酒哈4 小时前
Ubuntu 20.04 安装Anacada
linux·运维·ubuntu
oMcLin4 小时前
如何在Ubuntu 22.04 LTS上优化PostgreSQL 14集群,提升大数据查询的响应速度与稳定性?
大数据·ubuntu·postgresql