Centos7 安装docker-18.03.1-ce(离线安装)

一、引言

为了实现离线安装docker-18.03.1-ce这个想法,我遍寻网络,什么 RPM 搜索大法啦,yum localinstall 方法啦,都是复杂到不行。

二、终极解决

直接上网址: 
Install Docker CE from binaries (官方文档:通过二进制包安装 docker 社区版)

友情提示:访问该网页需要科学上网:)

这里,我把当前最新(2018-05-24)的 docker-18.03.1-ce 上传到了百度云,以方便大家下载使用: 
docker-18.03.1-ce 百度云密码:pah1

简单介绍下安装步骤:

1. 通过 FileZilla 等文件传输工具将 docker-18.03.1-ce.tar 放到用户目录下,并移动到该目录执行下述命令解压二进制包

$ tar xzvf docker-18.03.1-ce.tar

 

2. 将解压出来的 docker 文件所有内容移动到 /usr/bin/ 目录下

$ sudo cp docker/* /usr/bin/

 

3. 开启 docker 守护进程(这个与常规安装方式不一样)

$ sudo dockerd &

4. 现在你可以尝试着打印下版本号,试着看看 images,看看 info,看看容器了

$ sudo docker images

$ sudo docker ps -a

$ sudo docker --version

$ sudo docker info

都没有问题,则表示安装成功:)

至此,完美撒花!!!

三、docker注册为service

将以下文件放入 /usr/lib/systemd/system/docker.service 中,就可使用service docker restart/stop 等操作来启停docker

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

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)