# Making Python respect Docker memory limits

DevFeed: [Making Python respect Docker memory limits](<https://devfeed.tech/articles/making-python-respect-docker-memory-limits-37830.md>)

Original publisher: [Read original article](<https://carlosbecker.com/posts/python-docker-limits/>)

Author: Carlos Alexandro Becker

Published: 2020-11-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Carlos Becker](<https://devfeed.tech/sources/carlos-becker.md>)

Topics: [Docker](<https://devfeed.tech/topics/docker.md>), [Python](<https://devfeed.tech/topics/python.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Containers](<https://devfeed.tech/topics/containers.md>), [Processes](<https://devfeed.tech/topics/processes.md>)

Tags: [containers](<https://devfeed.tech/tags/containers.md>), [docker](<https://devfeed.tech/tags/docker.md>), [limits](<https://devfeed.tech/tags/limits.md>), [linux](<https://devfeed.tech/tags/linux.md>), [memory](<https://devfeed.tech/tags/memory.md>), [process](<https://devfeed.tech/tags/process.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

This article explains that Python running in Docker containers can see the host's available resources instead of the container's memory limit, potentially causing Linux's OOM killer to terminate the process. It presents a workaround that reads the limit and sets Python's maximum address space, then discusses testing, limitations, and Java's container support as a possible model.

## Source excerpt

If you run Python inside containers, chances are you have seen Linux's OOMKiller working at least a couple of times.