Linux离线安装Docker

上传安装包到服务器,并解压
tar xzvf docker-18.03.1-ce.tar
将解压出来的 docker 文件所有内容移动到 /usr/bin/ 目录下
cp docker/* /usr/bin/
开启 docker 守护进程(这个与常规安装方式不一样)
cd /usr/bin
dockerd &
运行以下命令,如果没问题,则表示安装成功
docker images
docker ps –a
docker –version
docker info
docker注册为service
在/usr/lib/systemd/system/下,新建docker.service ,就可使用service docker restart/stop 等操作来启停docker
vi /usr/lib/systemd/system/docker.service
复制黏贴以下代码到docker.service文件中

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=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 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服务设置为开机启动
systemctl enable docker.service
镜像加速
vi /etc/docker/daemon.json
insert 插入
{
“registry-mirrors”: [“https://dhq9bx4f.mirror.aliyuncs.com”]
}
重启docker服务
systemctl restart docker## 标题

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页