2、软件准备:docker-20.10.9.tgz
软件下载地址:
https://download.docker.com/linux/static/stable/x86_64/
软件准备:xshell。
3、看看系统是否存在docker。如果存在,看看版本,如果是 20.10.9以下版本,需要卸载重新安装。
命令: docker -v
4、使用xshell在虚拟机上创建目录:/opt/sqsh/,将文件上传到此目录下。
解压命令:tar -xvf docker-20.10.9.tgz
5、将解压后的docker目录中的所有内容拷贝到/usr/bin/目录下,放到此目录下相当于配置了环境变量即可以使用docker命令。
命令:cp -r /home/yunweishenji/sqsh/docker/* /usr/bin/
6、将docker注册为service:
命令:vim /etc/systemd/system/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=127.0.0.1
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
7、保存后给docker.service文件添加权限:
命令:chmod +x /etc/systemd/system/docker.service
8、重新加载配置文件(修改docker.service文件时都要重新加载下):
命令:systemctl daemon-reload
9、使用命令行启动docker:
命令:systemctl start docker
10、设置开机启动:
命令:systemctl enable docker.service
11、查看docker状态:
命令:systemctl status docker
12、查看docker版本
命令:docker -v