4
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dockerでメモリ不足を再現

Last updated at Posted at 2018-02-27

よくある「手元では動いたけどデプロイしたらメモリ不足でこけた」を手元で再現検証したかったので、
調べてみたらdockerで普通にできるみたいなので、こう。

ホスト側:メモリ4GBのところに
$ docker run --rm -it --memory 4g python:3.6.2 bash
コンテナ側:8GB確保して死んでしまうの図
root@c131a93a39db:/# cat <<EOD | python
> a = bytearray(8589934592)
> import time
> time.sleep(5)
> EOD
Killed

Docker for Mac 使ってる場合、 Preferences でデフォルトで2GBに制限されてるので、GUIから制限を増やしてやる必要あるので注意。
コマンドラインの --memory オプションで指定してもそれ以上割り当てられない。

4
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?