Docker离线安装教程——(一)
1、环境准备
- Linux CentOS7操作系统
- Docker安装文件下载
- 通过工具上传到服务器
2、安装Docker
-
进入安装目录,解压docker安装文件
#解压命令 tar -zxvf docker-20.10.9.tgz
-
将解压出来的docker文件夹内容移动到 /usr/bin/ 目录下
#拷贝 cp docker/* /usr/bin/
-
将docker注册为service(创建docker.service文件,并放入/etc/systemd/system/目录下。内容如下:)
[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
-
添加文件权限并加载docker.service文件
#添加权限 chmod +x /etc/systemd/system/docker.service #加载docker.service文件 systemctl daemon-reload
3、常用命令
#查看版本
docker -v
#查看状态
systemctl status docker.service
#设置开机自启
systemctl enable docker.service
#启动
systemctl start docker.service
#暂停
systemctl stop docker.service
#重新启动
systemctl restart docker.service