很旧的一个节点老是出问题,查询可能是因为存储驱动overlay本身的局限性所导致的,遂换成overlay2驱动。
1、确认目前docker版本及参数
[root@test docker]# docker info
Containers: 3
Running: 3
Paused: 0
Stopped: 0
Images: 30
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: extfs
Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-514.26.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 31.26GiB
Name: hckjarm
ID: XGKE:CZQE:RYV5:I2IO:SUML:ZOZU:WHHO:SONT:VR7M:VHCJ:FE5W:TUIB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
2、确认image版本
[root@test docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
production_nginx latest e4bb0aecdb15 3 months ago 107MB
production_php latest 1983f90f7de4 8 months ago 574MB
php 7.1-fpm-stretch 9641b421abf5 9 months ago 358MB
production_redis latest 61c5d36c8032 9 months ago 118MB
php 7.1-fpm 0f0f618f7b8c 9 months ago 391MB
redis 5.0 598a6f110d01 9 months ago 118MB
php 7.0-fpm 5b87b5758b16 2 years ago 381MB
nginx 1.13.3 b8efb18f159b 2 years ago 107MB
[root@test ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a2ca42445329 production_nginx "nginx -g 'daemon ..." 11 hours ago Up 11 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp production_nginx_1
128d4255e14d production_php "docker-php-entryp..." 11 hours ago Up 11 hours 8001/tcp, 0.0.0.0:9000->9000/tcp production_php_1
90851a567b3c production_redis "docker-entrypoint..." 11 hours ago Up 11 hours 0.0.0.0:6379->6379/tcp production_redis_1
3、确认(备份)挂载目录,
tar zcf /usr/local/src/web.tar.gz /root/web/
4、停止docker
systemctl stop docker
5、备份 /var/lib/docker 目录(目录比较大)
cp -au /var/lib/docker /var/lib/docker.bk
直接重命名目录
cd /var/lib/
mv docker docker.bak
6、修改docker参数
vim /etc/docker/daemon.json.
{
"registry-mirrors": ["https://0ev01gpj.mirror.aliyuncs.com"],
"storage-driver": "overlay2"
}
或
{
"registry-mirrors": ["https://0ev01gpj.mirror.aliyuncs.com"],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
docker image run fast
"registry-mirrors": ["https://0ev01gpj.mirror.aliyuncs.com"]
7、启动docker
systemctl start docker
如启动报错根据具体日志信息排错,正常即跳过
8、验证是否生效
docker info
Containers: 0
Images: 0
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Docker现在正在使用Overlay2存储驱动程序,并且已经使用所需的LowerDir、UpperDir、Merged和WorkDir结构自动创建了Overlay Mount。
9、下载相应版本image或直接docker-compose up
参考资料:
https://docs.docker.com/storage/storagedriver/overlayfs-driver/#prerequisites https://blog.csdn.net/textdemo123/article/details/102570449 https://blog.csdn.net/kjh2007abc/article/details/90554099