100

Running a python script in a docker container and everything seems to be running smoothly, seeing some STDOUT messages, about 5 minutes in I get a Killed message with no further explanation and the process stops. Querying a db so could be a disk space issue, could be OOM issue. I'm not sure but I have no idea where to find logs about this kill message so I can get to the root of this problem. Any ideas where these logs are?

Running docker-machine on Mac OSX.

That's really all the message says!

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

Thanks!

natsuki_2002
  • 24,239
  • 21
  • 46
  • 50
  • Post the stdout 'killed' message. As for the logs, you check the [Configure logging drivers](https://docs.docker.com/engine/admin/logging/overview/) documentation. – vmg Jun 07 '17 at 15:40
  • 2
    I swear thats all I get as a message! Posted it above anyways @vmg – natsuki_2002 Jun 07 '17 at 15:43
  • 7
    Killed usually means SIGKILL, OOM is the most common reason. In Linux `dmesg` would show you if this is the case, not sure about OSX. – jordanm Jun 07 '17 at 15:49

3 Answers3

148

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.

Tim Swast
  • 14,091
  • 4
  • 38
  • 61
Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 4
    I think this should be the accepted answer. The message "Killed" is so non helpful, that it's basically a bug in docker. – Jan Feb 24 '21 at 09:10
  • Being "out of memory" and thus being killed doesn't apply to MacOS only, of course! The same can be checked and configured on other docker hosts like Unix and Windows but also on cloud services like Kubernetes, OpenShift, AWS, GCP, Azure ... – Peter Wippermann Aug 06 '21 at 15:24
15

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).

Andy Shinn
  • 26,561
  • 8
  • 75
  • 93
5

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

This worked for me

Rafa Nogales
  • 614
  • 8
  • 13