HPCメモ

HPC(High Performance Computing)に関連したりしなかったりすることのメモ書き

docker環境構築 on Mac

travisCIでdockerを使えばubuntu以外の色々なOSでテストができるらしいということを知って、試行錯誤していたんですが try and errorで.travis.ymlを書き変えてはgithubにpushしてtraviCIに「ちゃうでー」と怒られるのを繰り返すのが辛くなってきたので 手元のmacにdockerの環境を作ってみました。

必要なのはこれだけ

> brew cask install docker
> open /Applications/Docker.app

アプリが立ち上がって、パスワードを聞かれるので正直に答えるとdockerが使えます。

> docker --version
Docker version 18.03.1-ce, build 9ee9f40
> docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

> docker run -it ubuntu bash
# uname -a
Linux 562794c23cf8 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
>docker rm `docker ps -a -q`
562794c23cf8
df64e1d5290b
9da30ff61d16
384cdda9dd3a

vagrantでvirtual boxを立ち上げるのに比べると、格段に早いですねー

まーchroot環境(微妙に違うか)だから、障害対応とかはvagrant + virtual boxで再現環境を作らんとだめだろうけど、普段の開発はこっちでも良いような気がしてきた。

あとはdocker環境でテストが動くように書き換えてから、.travis.ymlに再挑戦か・・・