docker安装Jenkins,解决总是容器总是Exited的问题,docker报错exited(137)

问题

docker容器莫名挂掉,docker ps -a 查看后报错:Exited (137) *** ago

这时通过docker logs查看容器内查不到任何报错日志,

网上的解决方案

网上说的是宿主文件夹的问题,
获得uid后,就可以修改了本地文件的权限了

sudo chown 1000:1000 /var/jenkins_home

但是我已经做了权限了,还是会有退出的问题,

我意识到可能不是这个问题

我单独查了Exited (137) 的错误

发现是内存溢出的问题,
命令
journalctl -k | grep -i -e memory -e oom

可见是因为OOMKilled,通过journalctl查看oom日志如下:
大量的内容溢出

Jun 12 21:26:15 localhost.localdomain kernel: Out of memory: Kill process 14786 (G1 Young RemSet) score 196 or sacrifice child
Jun 12 21:40:23 localhost.localdomain kernel: dockerd invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=-500
Jun 12 21:40:23 localhost.localdomain kernel:  [<ffffffff8ddc208d>] oom_kill_process+0x2cd/0x490
Jun 12 21:40:23 localhost.localdomain kernel:  [<ffffffff8ddc277a>] out_of_memory+0x31a/0x500
Jun 12 21:40:23 localhost.localdomain kernel: [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
Jun 12 21:40:23 localhost.localdomain kernel: Out of memory: Kill process 16645 (java) score 190 or sacrifice child
Jun 12 21:40:23 localhost.localdomain kernel: processor invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Jun 12 21:40:23 localhost.localdomain kernel:  [<ffffffff8ddc208d>] oom_kill_process+0x2cd/0x490
Jun 12 21:40:23 localhost.localdomain kernel:  [<ffffffff8ddc277a>] out_of_memory+0x31a/0x500
Jun 12 21:40:23 localhost.localdomain kernel: [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
Jun 12 21:40:23 localhost.localdomain kernel: Out of memory: Kill process 16656 (G1 Conc#0) score 190 or sacrifice child
Jun 12 21:43:07 localhost.localdomain kernel: alertmanager invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Jun 12 21:43:07 localhost.localdomain kernel:  [<ffffffff8ddc208d>] oom_kill_process+0x2cd/0x490
Jun 12 21:43:07 localhost.localdomain kernel:  [<ffffffff8ddc277a>] out_of_memory+0x31a/0x500
Jun 12 21:43:07 localhost.localdomain kernel: [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
Jun 12 21:43:07 localhost.localdomain kernel: Out of memory: Kill process 17274 (java) score 191 or sacrifice child
Jun 12 21:53:39 localhost.localdomain kernel: grpc_global_tim invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Jun 12 21:53:39 localhost.localdomain kernel:  [<ffffffff8ddc208d>] oom_kill_process+0x2cd/0x490
Jun 12 21:53:39 localhost.localdomain kernel:  [<ffffffff8ddc277a>] out_of_memory+0x31a/0x500
Jun 12 21:53:39 localhost.localdomain kernel: [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
Jun 12 21:53:39 localhost.localdomain kernel: Out of memory: Kill process 18375 (java) score 196 or sacrifice child

可以看到容器被干掉好多次
看来需要优化内存了
解决方案
我的是虚拟机上安装的Jenkins,所以我直接把虚拟机的内存增加到了8G,然后看看效果,

posted @ 2021-11-15 20:18  技术改变命运Andy  阅读(1381)  评论(0编辑  收藏  举报