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
相关推荐
こ进制掌控者3 小时前
Ubuntu server 24.04.3 设置静态IP
linux·tcp/ip·ubuntu
cdg==吃蛋糕5 小时前
solr cloud集群搭建 solr5+zookeeper
tcp/ip·docker·容器
段振轩6 小时前
Docker nginx容器部署前端项目。
前端·nginx·docker
conkl6 小时前
在ARM64 Ubuntu 20.04上部署Mailu邮件系统:深度排查Docker Bridge网络通信失败问题
linux·ubuntu·docker
什么半岛铁盒6 小时前
C++项目:仿muduo库高并发服务器------EventLoop模块的设计
linux·服务器·c++·mysql·ubuntu
云游9 小时前
IP地址管理:docker方式部署phpIPAMv1.7.3
运维·docker·ip·ipv4·ipv6
小闫BI设源码9 小时前
Docker Swarm主机编排
运维·docker·容器·容器编排·docker compose·依赖管理·多服务启动
Reicher9 小时前
Docker的介绍和使用
运维·docker·容器
退役小学生呀11 小时前
二十一、DevOps:从零建设基于K8s的DevOps平台(二)
运维·docker·云原生·容器·kubernetes·devops