接上篇,使用docker-compose装好filerun后,并且把docker-compose设置了rc.local开机启动
今天早上却无法访问,登陆上去发现filerun的容器结束了,另一个nextcloud的容器启动了,感觉是docker服务重启了,因为之前nextcloud可能设置了自动启动
但是uptime看系统没有重启,docker为什么会重启呢,又去找filerun容器结束的原因了
[root@localhost filerun]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422c2d4026b4 filerun/filerun "/filerun/entrypoint…" 14 hours ago Exited (137) 4 hours ago filerun_web_1
bfe186e71e54 mariadb:10.1 "docker-entrypoint.s…" 14 hours ago Exited (0) 4 hours ago filerun_db_1
58864d40dfa8 nextcloud "/entrypoint.sh apac…" 2 days ago Exited (0) 8 seconds ago nextcloud
05397c4206ad hello-world "/hello" 5 days ago Exited (0) 5 days ago nice_driscoll
看出filerun容器是4小时前退出的,那时候是凌晨三四点,不会是我操作的
依照从网上搜的方法,查看容器的日志
docker logs 9556bfa45b
{"log":"159.65.194.178 - - [10/Mar/2022:19:32:17 +0000] \"GET / HTTP/1.1\" 200 1230 \"-\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\"\n","stream":"stdout","time":"2022-03-10T19:32:17.443680697Z"}
{"log":"159.65.194.178 - - [10/Mar/2022:19:32:17 +0000] \"GET /favicon.ico HTTP/1.1\" 404 440 \"-\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\"\n","stream":"stdout","time":"2022-03-10T19:32:17.697761418Z"}
有一个欧洲的ip访问,但是没有报错
然后又搜到看容器退出时的返回码,从上面看出是137,据说要减128,得出是9,说是系统杀掉的,可能是OOM也就是内存超出
搜索dmesg无果,后面搜索?cat /var/log/messages|grep docker发现了问题,yum自动更新docker包然后重启了docker服务
这么看来设置开机调用docker-compose并不太好,还是要在docker容器启动参数上加上随docker服务自启动
搜索得到,在docker-compose.yml文件中相应的容器参数加上restart: always,如下
services:
db:
image: mariadb:10.1
restart: always
试了下
cd /root/filerun
docker-compose stop
docker-compose up -d --build
然后systemctl? restart? docker能filerun容器正常自启动
另docker inspect 422c2d4026b4能查看容器的一些参数,其中就能看到自启信息
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
|