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
相关推荐
蓝冰印4 小时前
HarmonyOS Next 快速参考手册
linux·ubuntu·harmonyos
别或许5 小时前
在centos系统下,安装MYSQL
linux·mysql·centos
丁丁丁梦涛5 小时前
CentOS修改MySQL数据目录后重启失败的问题及解决方案
linux·mysql·centos
DechinPhy5 小时前
Ubuntu挂载新硬盘
linux·运维·服务器·ubuntu
lht6319356125 小时前
Ubuntu Server 系统安装图形界面远程工具(RDP)
linux·运维·ubuntu
递归尽头是星辰6 小时前
Docker容器化核心知识体系:从入门到实践
docker·云原生·devops·容器化·镜像构建
鸠摩智首席音效师6 小时前
如何检查本地是否存在 Docker 镜像 ?
docker·容器
鸠摩智首席音效师6 小时前
如何在 Docker 中设置环境变量 ?
docker·容器
Reboot6 小时前
mini主机Windows系统更换为Ubuntu系统教程(不含图形化页面)
ubuntu
lht6319356128 小时前
Ubuntu Server系统安装谷歌浏览器
linux·运维·ubuntu