场景
CentOS7中Docker的安装与配置:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/119028701
在上面安装Docker时,CentOS是可以访问外网安装的。
如果是在内网服务器上,即这台服务器没法访问外网应该如何安装Docker。
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
首先下载docker的离线安装包
https://download.docker.com/linux/static/stable/x86_64/
这里选择20.10.7下载
下载之后将其上传到服务器上某路径下进行解压
tar -zvxf docker-20.10.7.tgz
解压之后将docker目录复制到/usr/bin目录下
cp docker/* /usr/bin/
然后新建一个docker.service系统配置文件
[Unit]
Description=Docker Application Container Engine
Documentation=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
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
将此文件复制到服务器上
这里是在本地Windows系统上新建文件然后使用xftp将其上传到CentOS服务器
然后在服务器上将其复制到/etc/systemd/system/下
cp docker.service /etc/systemd/system/
添加文件权限
chmod +x /etc/systemd/system/docker.service
重新加载配置文件
systemctl daemon-reload
启动docker
systemctl start docker
验证docker版本
docker version
卸载Docker
停止docker服务
systemctl stop docker
删除配置文件
rm -f /etc/systemd/system/docker.service
删除docker文件
rm -rf /usr/bin/docker*
重新加载配置文件
systemctl daemon-reload
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/136243.html