LoginSignup
1
1

More than 5 years have passed since last update.

【Python・R】docker containerのメモリ上限を解放する

Last updated at Posted at 2019-01-13

はじめに

※今回の内容はPython,Rに特有の内容ではありません

docker環境下でRやpythonを使っていると、すこし大きめのファイルを扱う場面で以下のmessageに遭遇することがあります。

R memory error

Error: cannot allocate vector of size ... Gb

python memory error

MemoryError

今回の記事では、上記を解決する手段を書いてみます。

環境

  • Pattern1, docker for mac
    • 仮想ホスト, HyperKit

  • Pattern2, docker toolbox

    • 仮想ホスト, VirtualBox
  • Pattern3, docker for windows

    • 仮想ホスト, Hyper-V

Pattern1. docker for macの場合

1. コンテナを載せている仮想ホストのメモリ上限を解放

  • docker > Preferences > Disk から、必要なメモリを指定

スクリーンショット 2019-01-13 14.13.06.png

2. docker run-mオプションで必要なサイズを指定

sample.sh
docker run -m 10000m --name sample rocker/hadleyverse

※仮想ホストのメモリ上限以上のサイズを割り当てることができないので注意です

Pattern2. docker toolbox with VirtualBox の場合

1. VMのメモリ上限を解放

  • VirtualBox > 設定 > システム から、必要なメモリを指定

2. docker run-mオプションで必要なサイズを指定

  • Pattern1と一緒です

Pattern3. docker for windows with Hyper-Vの場合

1. VMのメモリ上限を解放

  • docker > Settings > Advanced から、必要なメモリを指定

2. docker run-mオプションで必要なサイズを指定

  • Pattern1と一緒です

おわりに

  • どのくらいメモリを割り当てる必要があるかなどは、docker statsでコンテナの状況を確認すると把握できます
sample
docker stats

雑な備忘録ですが、どなたかのお役に立てれば幸いです。

References

How to assign more memory to docker container

1
1
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
1
1