说明:此方式适合无网状态下的服务器部署docker
一、先下载docker安装包
下载地址:https://download.docker.com/linux/static/stable/x86_64/
下载对应的docker-18.06.3-ce.tgz这个压缩文件到本地
二、将docker-18.06.3-ce.tgz上传到linux服务器并解压
上传命令:rz docker-18.06.3-ce.tgz
解压:tar -zxvf docker-18.06.3-ce.tgz
三、将解压文件复制到 /usr/bin/ 目录下
执行复制命令:cp docker/* /usr/bin/
四、进入/etc/systemd/system/ 创建docker.service,并写入配置
进入:cd /etc/systemd/system/
创建并编辑:vi docker.service
写入表格下的内容:注意:ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=192.168.200.128这个ip改成你服务器的IP
[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.200.128 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 777 docker.service
重启配置:systemctl daemon-reload
五、启动docker并设置开机启动
启动:systemctl start docker
开机启动:systemctl enable docker.service
查看docker状态:systemctl status docker
如果修改了配置文件重启docker命令:service docker restart
六、docker命令
版本:docker -v
查看镜像:docker images
查看容器:docker ps -a
离线安装到此完成~