dockeruiを動かしてみるまで
dockeruiとは
Github:crosbymichael / dockeruiで作られているブラウザからDockerコンテナを管理するGUIアプリケーション、という認識で良いのでしょうか?DockerのRemoteAPIを叩いてGUIで可視化する試みを行なっているようです。まだまだ開発途中らしいですが、いろいろと記事が上がっていたので触ってみることにしました。
DockerUI is a web interface to interact with the Remote API. The goal is to provide a pure client side implementation so it is effortless to connect and manage docker. This project is not complete and is still under heavy development.
起動後の画面はこんな感じ。これを目指して環境構築して行きます。
まずは、VagrantfileにプライベートIPを割り振っておきます。 192.168.33.10 はVagrantで指定したいPrivate IP
Vagrantfile(docker公式レポジトリのやつ)
config.vm.provider :virtualbox do |vb, override| override.vm.provision :shell, :inline => $vbox_script vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] end config.vm.network :private_network, ip: "192.168.33.10" end
お次はDocker自体の設定ファイルを弄って行きます。 unix socketとtcpとの設定を同時に設定しても問題ないようです。オプション毎回付けるのも面倒なので、ここで指定しておきます。 http://docs.docker.io/en/latest/commandline/cli/#daemon
daemon
Usage of docker:
-D=false: Enable debug mode
-H=[unix:///var/run/docker.sock]: Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise
-api-enable-cors=false: Enable CORS headers in the remote API
-b="": Attach containers to a pre-existing network bridge; use 'none' to disable container networking
-bip="": Use the provided CIDR notation address for the dynamically created bridge (docker0); Mutually exclusive of -b
-d=false: Enable daemon mode
-dns="": Force docker to use specific DNS servers
-g="/var/lib/docker": Path to use as the root of the docker runtime
-icc=true: Enable inter-container communication
-ip="0.0.0.0": Default IP address to use when binding container ports
-iptables=true: Disable docker's addition of iptables rules
-p="/var/run/docker.pid": Path to use for daemon PID file
-r=true: Restart previously running containers
-s="": Force the docker runtime to use a specific storage driver
-v=false: Print version information and quit
vim /etc/init/docker.conf
description "Docker daemon" start on filesystem and started lxc-net stop on runlevel [!2345] respawn script DOCKER=/usr/bin/$UPSTART_JOB DOCKER_OPTS= if [ -f /etc/default/$UPSTART_JOB ]; then . /etc/default/$UPSTART_JOB fi #"$DOCKER" -d $DOCKER_OPTS "$DOCKER" -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock -d -api-enable-cors $DOCKER_OPTS end script
Dockerを再起動する
service docker restart
そのあと、以下のコマンドを入力するだけ。ローカルにイメージが存在しない場合は勝手にリモートに探しに行ってくれるので、pullとかbuildとか考えなくてもおっけー。
docker run -d -p 9000:9000 crosbymichael/dockerui -e="http://192.168.33.10:4243"
手元のMacから http://192.168.33.10:9000 へアクセス。 すると、ご覧のように起動していることを確認出来ます。
とりあえず、使い勝手確かめてから色々弄ろうかなとか思ってるときには試してみてください。
とふと考えて、コンテナのこのアプリがホストのIP確認できているのはどうしてなんだろうかと思い始めた。 docker0でブリッジしてるみたいな感じらしいから、そこらへんのIPでホストにアクセス出来るのはわかるけど(172.17.XX.XX)。0.0.0.0:4243ですべてのIPでポート受け付けろと指定しているのは分かるけど。192.168.XX.XXでアクセス出来ている理由がよくわからん。ネットワーク周りの知識無さすぎて泣きたい。ここら辺勉強出来る良い教材を教えてください。。。