永远热爱,永远期待❤|

StupidCN

园龄:6年1个月粉丝:0关注:0

Linux离线安装Docker

Linux离线安装Docker

查看服务器架构信息

uname -m

下载安装包并传输到指定服务器

  • 访问https://download.docker.com/linux/static/stable/ 下载对应服务器架构下的压缩包,架构目录下有对应的docker版本

解压并拷贝命令

# 解压安装包
tar -zxvf docker-aarch64-24.0.5.tgz
# 将解压出来的docker文件复制到 /usr/bin/ 目录下
cp docker/* /usr/bin/

配置systemd服务

  • 由于不同的系统,服务管理器的方式和工具不一样,请各位自行查询一下自己的系统对应服务管理器该如何配置
  • centos7和openeuler: systemd
  1. 创建并修改docker.service文件/usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target
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
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
  1. 设置权限
chmod 777 /usr/lib/systemd/system/docker.service
  1. 重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload
  1. /usr/lib/systemd/system//etc/systemd/system/区别和联系

具体区别联系可参考:https://www.cnblogs.com/TonvyLeeBlogs/articles/13762400.html

  • 正常情况下通过daemon-reload,两个目录下的service都会被重载
  • etc和usr如果有重名的service,则etc的service会覆盖usr下的service,因为etc的service优先级要高
  • 系统每次启动都会读取etc下的service,所以当你执行systemctl enable的时候,安装在usr下的service会被ln -s/etc/systemd/system/multi-user.target.wants/

配置docker数据目录

没有特殊需求的话,可以跳过这一步;当然也可以修改,下面是修改docker数据目录的方式

  1. 默认docker镜像下载目录为/var/lib/docker,我们可以修改为其他目录,比如/data/docker
mkdir /data/docker
  1. 修改docker配置文件/etc/docker/daemon.json
{
"data-root": "/data/docker"
}
  1. 启动docker服务
systemctl start docker

启停docker服务

  1. 启动docker服务
systemctl start docker
  1. 设置开机启动
systemctl enable docker.service
  1. 查看docker状态
systemctl status docker
  1. 验证
systemctl status docker

本文作者:StupidCN

本文链接:https://www.cnblogs.com/adblogs/p/18630839

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   StupidCN  阅读(79)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起