linux centOS离线安装docker

1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

通过 uname -r 命令查看你当前的内核版本
在这里插入图片描述
2、下载docker的安装文件
https://download.docker.com/linux/static/stable/x86_64/
下载自己合适的版本,这里下载18.03.1
linux centOS离线安装docker_第1张图片
3、解压并移动到/usr/bin目录下
tar zxf docker-18.06.1-ce.tgz && mv docker/* /usr/bin/ && rm -rf docker*.tgz //解压切移动binary到 /usr/bin

注意:如果移动到别的目录有点问题,systemctl脚本启动不起来,具体原因还在寻找中

4、进入/etc/systemd/system/目录,并创建docker.service文件
cd /etc/systemd/system/
touch docker.service
linux centOS离线安装docker_第2张图片
5、复制以下信息到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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP
# 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

ExecStart可以自定义docker的解压目录,其他不用动

6、给docker.service文件添加执行权限
sudo chmod 777 /etc/systemd/system/docker.service

7、重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload //重载systemd下 xxx.service文件
systemctl start docker //启动Docker
systemctl enable docker.service //设置开机自启
启动成功
linux centOS离线安装docker_第3张图片

常见报错:
在这里插入图片描述
解决方法:
1、查看daemon文件
vim /etc/docker/daemon.json
写入保存

{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

2、关闭防火墙和selinux
systemctl stop firewalld
systemctl status firewalld
setenforce
getenforce

重载docker配置文件
systemctl daemon-reload
重启docker
systemctl restart docker

写在最后:
docker的根目录默认是、/var/lib/docker下,可通过docker info查看,根目录空间较小,可对docker根目录进行切换
linux centOS离线安装docker_第4张图片
首先停止服务
sudo systemctl stop docker
移动至/app目录下
mv /var/lib/docker /app/docker
修改daemon配置
sudo vim /etc/docker/daemon.json
添加"graph":"/app/docker"
linux centOS离线安装docker_第5张图片

将/app/docker所有者换成weblogic
chown -R weblogic:weblogic /app/docker

你可能感兴趣的:(docker,linux,centos)