千家信息网

Centos7如何离线安装Docker

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,这篇文章将为大家详细讲解有关Centos7如何离线安装Docker,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。下载Docker并安装docker包下载地址#下载d
千家信息网最后更新 2025年02月01日Centos7如何离线安装Docker

这篇文章将为大家详细讲解有关Centos7如何离线安装Docker,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

下载Docker并安装

docker包下载地址

#下载docker-20.10.0包https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz#上传到Centos系统/data/目录,如scp docker-20.10.0.tgz root@192.168.0.5:/data/#进入data目录,解压docker包cd /datatar -zxvf docker-20.10.0.tgz#将解压出来的docker文件内容移动到 /usr/bin/ 目录下cp docker/* /usr/bin/#查看docker版本docker version#查看docker信息docker info

配置Docker开机自启动服务

#添加docker.service文件vi /etc/systemd/system/docker.service#按i插入模式,复制如下内容:
[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=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 dockerExecStart=/usr/bin/dockerdExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s  [Install]WantedBy=multi-user.target
#添加文件可执行权限chmod +x /etc/systemd/system/docker.service#重新加载配置文件systemctl daemon-reload#启动Dockersystemctl start docker#查看docker启动状态systemctl status docker#查看启动容器docker ps#设置开机自启动systemctl enable docker.service#查看docker开机启动状态 enabled:开启, disabled:关闭systemctl is-enabled docker.service

关于"Centos7如何离线安装Docker"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

0