LoginSignup
0
0

More than 3 years have passed since last update.

Dockerfile書いてみた

Posted at

この前の記事で作成した環境をDockerfileで書いてみたので、メモ。

まず書いて動かしてみた

効率的に安全な Dockerfile を作るには、実際にshell上で動かしたコマンドをそのままDockerfileにすれば良いとのことで、メモから抽出して作ったのがこちら。

FROM ubuntu:18.04

ENV https_proxy "xxxxxx"
ENV http_proxy "xxxxxx"

RUN apt -y update
RUN apt -y install vim
RUN apt -y install python3.8
RUN apt -y install curl
RUN apt -y install python3-pip
RUN pip3 install numpy
RUN pip3 install torch

Warningが出てくるが無視してOKらしい

dockerbuild下にDockerfileを配置して、

docker image build -t myubuntu dockerbuild

すると、何やら色々動いてくれるが、ところどころ以下のWarningが出てくる…

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
debconf: delaying package configuration, since apt-utils is not installed

この記事によると全然無視して良いっぽい。

Torchのinstallでkillが発生する

いい感じに動いてくれていると思ったら、Torchのinstall中にいきなりkillで終了してしまい、最後でうまくいかなかった。

こちらの記事がすでに通った道で、OOMでのkillが走っていた模様。
こちらはdocker for Windowsだが、解決策は一緒で「setting」「Advanced」からMemoryの部分をいじる。
自分は2048MBから4096MBまで上げたところ、docker imageのbuildは無事終了。

docker image ls

でmyubuntuが追加されていることを確認してrun。

docker run -it -d --name ubuntu1804 myubuntu
docker exec -it ubuntu1804 /bin/bash

bashからpython3, torchの確認までできたので、この前の記事と同じ環境がDockerfileで作れたはず!

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