Mac OSのParallelsで利用できるboot2dockerでdockerを動かす

前回、kvm上のubuntuでdockerをインストールして入門しようとしましたがうまく行きませんでした 入門のときに面倒なことは避けるほうが良いです。そこで、手っ取り早くVagrantでdockerのイメージを入れて、dockerしてみようと思います。

セットアップ方法

前提条件は

  • parallelsがインストール済み
  • vagrantがインストール済み
  • Download Vagrant - Vagrant
  • brew経由で入れようとするとvirtualboxも入れようとしていたので公式から落として入れました(確か)
  • vagrant-parallelsプラグインをインストールする。

後は公式の方法に従うだけ!しかも丁寧にvagrant-parallelsのインストールも書かれていました。

Parallels/boot2docker-vagrant-box

Hello Worldする専用のコンテナイメージがあるんですね。実行してみると

hiroshi-no-MacBook-Air:boot2docker hiroshi$ docker run hello-world
Unable to find image 'hello-world:latest' locally
hello-world:latest: The image you are pulling has been verified
511136ea3c5a: Pull complete
31cbccb51277: Pull complete
e45a5af57b00: Pull complete
Status: Downloaded newer image for hello-world:latest
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.
(Assuming it was not already locally available.)
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

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

これでいいってことだよね?行けますね :-)

さくらクラウドの記事を写経する

docker run --name redmine -d -p 80:80 sameersbn/redmine

動いているけど、localhostでアクセス出来ない。ってそうか。parallelsだからそっちのlocalhostになるのか。ということでVagrantfileにportfowerdの設定を施す

$ vim Vagrantfile

# 以下の場所でポートフォワーディングを有効化
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080

で実行してもアクセス出来ない。どういうこと?

シェルにアクセスできるか調べてみると

hiroshi-no-MacBook-Air:boot2docker hiroshi$ docker run --name redmine -it sameersbn/redmine /bin/bash
ERROR:
  Please configure the database connection.
  Refer http://git.io/JkE-cw for more information.
  Cannot continue without a database. Aborting...

シェル見れたけど、ログイン出来ない?で、丁寧にメッセージが。
データベースコネクションしてねと言われていますね。指定されたURLがこれになって

docker-redmine/README.md at master · sameersbn/docker-redmine

どうやら、このDocker imageはさくらのナレッジの解説と内容が変わったらしくて、データベースをコネクションしないと起動してくれないようです。

使い方はちゃんと配布先の情報を元にした方がいいですね。

続きます

せめてredmineまではちゃんと動かしたかったのですが、眠いので次回へ

About Me

買ったり作ったり考えたり試したの日々の記録です