下载Docker并装置

docker包下载地址

#下载docker-20.10.0包https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz#上传到Centos零碎/data/目录,如scp docker-20.10.0.tgz root@192.168.0.5:/data/#进入data目录,解压docker包cd /datatar -zxvf docker-20.10.0.tgz#将解压进去的docker文件内容挪动到 /usr/bin/ 目录下cp docker/* /usr/bin/#查看docker版本docker version#查看docker信息docker info

配置Docker开机自启动服务

#增加docker.service文件vi /etc/systemd/system/docker.service#按i插入模式,复制如下内容:
[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=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 dockerExecStart=/usr/bin/dockerdExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s  [Install]WantedBy=multi-user.target
#增加文件可执行权限chmod +x /etc/systemd/system/docker.service#从新加载配置文件systemctl daemon-reload#启动Dockersystemctl start docker#查看docker启动状态systemctl status docker#查看启动容器docker ps#设置开机自启动systemctl enable docker.service#查看docker开机启动状态 enabled:开启, disabled:敞开systemctl is-enabled docker.service