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
相关推荐
鸡吃丸子2 小时前
初识Docker
运维·前端·docker·容器
qq_455760853 小时前
docker run
运维·docker·容器
叽里咕噜怪3 小时前
Docker-基础
运维·docker·容器
番知了4 小时前
Ubuntu 22.04 常用命令清单
linux·运维·ubuntu
FF-Studio5 小时前
Ubuntu 24.04 磁盘爆满“灵异“事件:Btrfs, Snapper 与删不掉的空间
linux·运维·人工智能·ubuntu
极地星光5 小时前
Ubuntu 16.10 启动时 networking.service 缓慢问题
linux·ubuntu
Roadinforest5 小时前
如何使用 keyd 定制 Caps Lock:拯救你坏掉的 Left Control 键(Linux-Ubuntu)
linux·ubuntu
舞动青春885 小时前
Ubuntu安装QEMU过程及问题记录
linux·学习·ubuntu
知识分享小能手5 小时前
Ubuntu入门学习教程,从入门到精通,Ubuntu 22.04的基本配置 (3)
linux·学习·ubuntu
Joren的学习记录6 小时前
【Linux运维大神系列】Docker详解(二)
linux·运维·docker