- 一、CentOS7离线安装Docker步骤
- 二、CentOS7离线卸载Docker步骤
1、docker安装包下载地址
-
https://download.docker.com/linux/static/stable/x86_64/
2、将下载的docker-18.06.3-ce.tgz文件上传到centos7系统上(lz上传到了/home/docker目录下),并执行tar命令解压,如下图:
[root@CenOS-1 docker]# tar -zxvf docker-18.06.3-ce.tgz
3、将/home/docker目录下解压出来的所有docker文件复制到 /usr/bin/ 目录下,如下图:
[root@CenOS-1 docker]# cp docker/* /usr/bin/
4、将docker注册为service,进入/etc/systemd/system/目录,并创建docker.service文件,如下图:
[root@CenOS-1 docker]# cd /etc/systemd/system/
[root@CenOS-1 system]# touch docker.service
5、编辑docker.service文件,将以下内容复制到docker.service文件中,如下图:
-
注:以下内容中 --insecure-registry=192.168.3.10 此处改为你自己服务器ip。
[root@CenOS-1 system]# vim 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 --selinux-enabled=false --insecure-registry=192.168.3.10 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
6、给docker.service文件添加执行权限,如下图:
[root@CenOS-1 system]# chmod 777 /etc/systemd/system/docker.service
7、重新加载配置文件,如下图:
- 注:每次修改docker.service这个文件时都要重新加载下。
[root@CenOS-1 system]# systemctl daemon-reload
8、启动Docker服务,如下图:
[root@CenOS-1 system]# systemctl start docker
9、设置开机启动Docker服务,如下图:
[root@CenOS-1 system]# systemctl enable docker.service
10、验证docker是否启动成功,如下图:
-
查看Docker状态,显示active(running)表示启动成功
[root@CenOS-1 system]# systemctl status docker
-
查看Docker版本
[root@CenOS-1 system]# docker -v
11、配置镜像加速器,默认是到国外拉取镜像速度慢,如下图:
-
编辑 /etc/docker/目录下的daemon.json文件,将以下内容复制到daemon.json文件中,如下图:
[root@CenOS-1 system]# vim /etc/docker/daemon.json
{"registry-mirrors": ["http://hub-mirror.c.163.com"]}
-
重启docker,使其daemon.json文件配置生效,如下图:
参考:https://blog.csdn.net/qq_20466211/article/details/108762800 1、删除服务
#取消开机自启
[root@CenOS-1 system]# systemctl disable docker
#取消注册文件
[root@CenOS-1 system]# rm -rf /etc/systemd/system/docker.service
2、删除命令
[root@CenOS-1 system]# rm -rf /usr/bin/containerd
[root@CenOS-1 system]# rm -rf /usr/bin/containerd-shim
[root@CenOS-1 system]# rm -rf /usr/bin/ctr
[root@CenOS-1 system]# rm -rf /usr/bin/runc
[root@CenOS-1 system]# rm -rf /usr/bin/docker*
3、删除配置
[root@CenOS-1 system]# rm -rf /etc/docker/
4、删除镜像或容器
[root@CenOS-1 system]# rm -rf /var/lib/docker