Help us understand the problem. What is going on with this article?

docker-machine 触ってみた

More than 3 years have passed since last update.

はじめに

docker-machine なるものが出てきたので、触ってみました。幸いなことに素晴らしいリファレンスもあり、導入には困りませんでした。

インストール

環境はこちら。ダウンロードは公式からが確実かと思います。

  • OS X Yosemite(10.10.2)
  • VirtualBox 4.3.24
% sudo mv ~/Downloads/docker-machine_darwin-amd64 /usr/bin/docker-machine
% sudo chmod +x /usr/bin/docker-machine
% docker-machine -v
docker-machine version 0.1.0

docker自体はbrewでサクッとインストール。

% brew install docker

docker ホストの作成

% docker-machine ls
NAME   ACTIVE   DRIVER   STATE   URL   SWARM
% docker-machine create --driver virtualbox dev
INFO[0000] Creating CA: /Users/koide/.docker/machine/certs/ca.pem
INFO[0000] Creating client certificate: /Users/koide/.docker/machine/certs/cert.pem
INFO[0001] Downloading boot2docker.iso to /Users/koide/.docker/machine/cache/boot2docker.iso...
INFO[0012] Creating SSH key...
INFO[0012] Creating VirtualBox VM...
INFO[0017] Starting VirtualBox VM...
INFO[0017] Waiting for VM to start...
INFO[0050] "dev" has been created and is now the active machine.
INFO[0050] To point your Docker client at it, run this in your shell: $(docker-machine env dev)
% docker-machine ls
NAME   ACTIVE   DRIVER       STATE     URL                         SWARM
dev    *        virtualbox   Running   tcp://192.168.99.100:2376

環境変数の確認

% docker-machine env dev
export DOCKER_TLS_VERIFY=yes
export DOCKER_CERT_PATH=/Users/koide/.docker/machine/machines/dev
export DOCKER_HOST=tcp://192.168.99.100:2376
% docker-machine config dev
--tls --tlscacert=/Users/koide/.docker/machine/machines/dev/ca.pem --tlscert=/Users/koide/.docker/machine/machines/dev/cert.pem --tlskey=/Users/koide/.docker/machine/machines/dev/key.pem -H="tcp://192.168.99.100:2376"

リファレンスにならって、今回はexportコマンドを実行せずに、docker-machine configコマンドを使用してみる。

docker コマンドの実行

% docker $(docker-machine config dev) ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

docker-compose でコンテナ作成

ここまで順調なので(フラグ)、
作成したdocker-machineを使って、docker-composeでコンテナを作成してみる。

% docker-machine ssh dev
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.5.0, build master : a66bce5 - Tue Feb 10 13:31:27 UTC 2015
Docker version 1.5.0, build a8a31ef
docker@dev:~$

公式にならって、docker-composeをインストール。

docker@dev:~$ curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
docker@dev:~$ chmod +x /usr/local/bin/docker-compose

バージョン確認。

docker@dev:~$ docker-compose --version
-sh: docker-compose: not found

あれ?

docker@dev:~$ ls -l /usr/local/bin/docker-compose
-rwxr-xr-x    1 docker   staff      5257430 Mar 10 02:06 /usr/local/bin/docker-compose
docker@dev:~$ which docker-compose
/usr/local/bin/docker-compose

???
何故か起動できない…(´・ω・`)

原因

調べてみると、現状boot2dockerでdocker-composeが使えないみたい。残念ー

docker-compose not found in boot2docker

おわりに

docker-composeは残念でしたが、思っていたよりも簡単にdocker環境を構築出来ました。
導入が手軽なので自分のような情弱エンジニアには大変助かっております。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした