方法一.使用二进制文件安装(推荐)
之前使用下面方法二rpm包安装成功过,但是在另外不能上网的服务器,因为缺少依赖没有安装成功,所以只能使用方法1,二进制文件离线安装。
下载docker安装文件:
https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
上传到服务器解压到/usr/bin/:
tar -zxvf docker-18.06.3-ce.tgz
cp docker/* /usr/bin/
进入/etc/systemd/system/目录,并创建docker.service文件
[root@localhost java]# cd /etc/systemd/system/
[root@localhost system]# touch docker.service
[root@localhost system]# vi 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=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 /etc/systemd/system/docker.service
重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
[root@localhost system]# systemctl daemon-reload
启动
[root@localhost system]# systemctl start docker
设置开机启动
[root@localhost system]# systemctl enable docker.service
查看docker状态
[root@localhost system]# systemctl status docker
方法二.使用rpm安装包安装
下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
下载安装包
containerd.io-1.2.5-3.1.el7.x86_64.rpm
docker-ce-18.09.5-3.el7.x86_64.rpm
docker-ce-cli-18.09.5-3.el7.x86_64.rpm
docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
执行rpm安装命令
rpm -ivh *.rpm
https://blog.csdn.net/sessionsong/article/details/102628738