LoginSignup
7
6

More than 5 years have passed since last update.

dockerでDrupalを動かしてみる(MaxOS X 10.9.5) (未完成)

Last updated at Posted at 2014-09-30

やりたいこと

  • Docker触ったことないので動かしてみる(とりあえずお手軽にboot2dockerから始めてみる)
  • 業務でCMSを扱うようになるので、今アツいらしいDrupalに触れてみる

boot2dockerの導入

はじめてのDocker on Mac OS X(2014/04/09)を見てスタート。。。したものの、上記サイトはdocker0.9.1でちと古かった模様。
(boot2dockerの公式pkgが出来たのでhomebrewは対応しなくなるとかって記述を見た)

Qiitaに"Docker Mac"ってクエリ投げたら1.0対応の投稿があった:Mac OS X に Docker 1.0 をインストールする(2014/06/10) ので、この投稿を参考に進める。

boot2docker公式を見たら8/23にv1.2.0がリリースされてたのでDL。
pkg叩いてあっさりインストールし、Dockerhubアカウントを作成(Githubアカウントとリンク)して、いよいよboot2dockerを実行。
実行したらターミナルが起動して、ダダダッと以下コマンドが走る。

$ bash
bash-3.2$ unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
bash-3.2$ mkdir -p ~/.boot2docker
if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
/usr/local/bin/boot2docker init 
/usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375
docker version
bash-3.2$ if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
bash-3.2$ /usr/local/bin/boot2docker init 
Generating public/private rsa key pair.
Your identification has been saved in /Users/kamehiro17/.ssh/id_boot2docker.
Your public key has been saved in /Users/kamehiro17/.ssh/id_boot2docker.pub.
The key fingerprint is:
7d:bc:70:8b:48:a4:5e:de:b8:5b:e2:0f:3f:78:eb:45 kamehiro17@tkameda-mba.local
The key's randomart image is:
+--[ RSA 2048]----+
(省略)
+-----------------+
bash-3.2$ /usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375
Waiting for VM and Docker daemon to start...
..............................................
Started.

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.xxx.xxx:2375

bash-3.2$ docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): fa7b24f
OS/Arch (client): darwin/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): fa7b24f
bash-3.2$ 

docker upしたようなので、チュートリアルに則ってHello Worldを叩いてみる。

$ docker run hello-world
Unable to find image 'hello-world' locally
Pulling repository hello-world
bf16b6e27882: Download complete 
511136ea3c5a: Download complete 
8f5550346e61: Download complete 
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/
$ 

Hello from Dockerが出たのできっとOKなのだろう。


何をどうしていいかもよく分かっていないので、再度Qiitaを検索。
Macのdockerを1.0にアップグレードする(2014/06/17)を参考にさせていただいた。
もちろん公式ガイドも。

$ export DOCKER_HOST=tcp://192.168.xxx.xxx:2375
$ boot2docker init
Virtual machine boot2docker-vm already exists
$ boot2docker up
Waiting for VM and Docker daemon to start...
..
Started.
Your DOCKER_HOST env variable is already set correctly.
$ boot2docker ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 1.2.0
             3.16.1-config-file : e75396e - Fri Aug 22 06:45:30 UTC 2014
docker@boot2docker:~$ 

あ、かわいい。


Drupalを動かしてみる

ricardoamaro/drupal-lampを試す。

bash-3.2$ docker run -d -p 82:80 ricardoamaro/drupal-lamp
Unable to find image 'ricardoamaro/drupal-lamp' locally
Pulling repository ricardoamaro/drupal-lamp
e12abb230ef5: Download complete 
(〜中略〜)
517b75a41a54: Download complete 
02024baddfa37bd9650eb2df310cb90b706210b5d4d4a16f9810207c4183bb18
bash-3.2$ 

いけたということで、IP確認して接続してみる。

$ boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103

ブラウザから192.168.59.103:82に接続。

kobito.1412090159.021815.png

いけた。
プロセス確認してみる。

$ docker ps
CONTAINER ID        IMAGE                             COMMAND                CREATED             STATUS              PORTS                    NAMES
02024baddfa3        ricardoamaro/drupal-lamp:latest   "/bin/bash /start.sh   28 minutes ago      Up 30 seconds       0.0.0.0:82->80/tcp       nostalgic_stallman   

いいね。きちんと動いている模様。
サイト作成できるのかな?と、まずはアカウントの作成を試みる、が、、、

kobito.1412090684.985199.png

kobito.1412090735.343385.png

システムからのメール送信が出来ない模様。
今日のところはここまで。

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