docker安装方式
docker目前支持centos7及以后的版本,要求64位操作系统,内核版本至少为3.10
一、docker在线安装
1.1、安装docker所需的工具
-
yum-utils 提供了 yum-config-manager,用于后续添加docker仓库源
-
device-mapper-persistent-data和lvm2 是device mapper存储驱动程序需要。Device Mapper 是 Linux2.6 内核中支持逻辑卷管理的通用设备映射机制,它为实现用于存储资源管理的块设备驱动提供了一个高度模块化的内核架构。
# yum install yum-utils device-mapper-persistent-data lvm2 -y
1.2、添加docker稳定版本的yum软件安装源
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
1.3、查询可安装docker软件版本
# yum list docker-ce --showduplicates
1.4、安装最新版本的docker软件
# yum install docker-ce -y
1.5、查看docker安装版本
# docker version
1.6、更改国内的docker镜像下载源
# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://yuiile7n.mirror.aliyuncs.com"]
}
二、docker离线安装
2.1、rpm包安装方式,下载地址:
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
2.2、离线二进制安装包,下载地址:
https://download.docker.com/linux/static/stable/x86_64/
2.3、安装过程
# tar -zxvf docker-20.10.14.tgz
# cp docker/* /usr/bin/
# cd /etc/systemd/system/
# vim docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=[https://docs.docker.com](https://docs.docker.com)
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=192.168.94.110
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
--insecure-registry=192.168.94.110 改为自己服务器的IP地址
# chmod 777 docker.service
# systemctl daemon-reload
# systemctl start docker
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现