Docker 进程被神秘的“已杀死”消息杀死

在一个 docker 容器中运行一个 python 脚本,一切似乎运行得很顺利,看到一些 STDOUT 消息,大约5分钟后,我得到一个 Killed消息,没有进一步的解释,进程停止。查询数据库可能是磁盘空间问题,也可能是 OOM 问题。我不确定,但是我不知道在哪里可以找到关于这个 kill 消息的日志,这样我就可以找到这个问题的根源。知道这些日志在哪吗?

在 Mac OSX 上运行码头机。

这真的是所有的消息说!

root@c7b800e0f276:/opt/mymodule# python
Python 2.7.13 (default, May  1 2017, 22:44:36)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mymodule import model
>>> model.run('2017-04-01')
INFO:Deleting from input table.
INFO:Inserting into input table.
INFO:Querying input table for chunk.
Killed
root@c7b800e0f276:/opt/mymodule# exit

谢谢!

36755 次浏览

With Docker for Mac, you can get into the host VM namespace with:

docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh

Then run chroot /host to change root to the host mount. Now, you can use utilities like dmesg to check for any OOM message (like the comments to your question suggest).

Docker for Mac limits the resource available to 2GB by default! This is too low for the app that I run. The solution is to increase the memory limit to 8GB, or however much your app needs.

(I am having similar issue albeit using a JVM application, not Python, and reached here by Google searching. From the deleted answer by @sergiu I am able to figure out the issue.)

Get started with Docker for Mac says:

Advanced

Advanced settings are:

CPUs: By default, Docker for Mac is set to use half the number of processors available on the host machine. To increase processing power, set this to a higher number; to decrease, lower the number.

Memory: By default, Docker for Mac is set to use 2 GB runtime memory, allocated from the total available memory on your Mac. To increase RAM, set this to a higher number; to decrease it, lower the number.

Swap: Configure swap file size as needed. The default is 1 GB.

This happens because your application is consuming all the RAM available. You can monitor the RAM consumption and increase it.

This worked for me