読者です 読者をやめる 読者になる 読者になる

@Konboi memo

主に技術に関してつらつらと。

docker-mahcine使ってみた

docker docker-machine

init

$ docker-machine create —driver virtual box doc
INFO[0000] Creating SSH key...
INFO[0000] Creating VirtualBox VM...
ERRO[0009] Error creating machine: exit status 1
WARN[0009] You will want to check the provider to make sure the machine and associated resources were properly removed.

debugモードで起動してみる

$ docker-machine rm doc
$ docker-machine —debug create --driver virtualbox doc                                          
...                                                                                                                                   
STDERR: Oracle VM VirtualBox Command Line Management Interface Version 5.0.2
...

docker-machine create fails on Mac OSX 10.10.4

4.3系なら動くようなのでここからpkgダウンロードしてダウングレード

4.3.30 なら動いた

docker-machineでdockerを試せる環境を作ってみる

 $ docker-machine ls 
NAME   ACTIVE   DRIVER   STATE   URL   SWARM

何もない

$ docker-machine create —driver virtual box doc
INFO[0000] Creating SSH key...
INFO[0000] Creating VirtualBox VM...
INFO[0009] Starting VirtualBox VM...
INFO[0009] Waiting for VM to start...
INFO[0056] "doc" has been created and is now the active machine.
INFO[0056] To point your Docker client at it, run this in your shell: eval "$(docker-machine env doc)"
$ docker-machine ls 
NAME   ACTIVE   DRIVER       STATE     URL                         SWARM
doc    *        virtualbox   Running   tcp://192.168.99.101:2376

できてるっぽい

いろいろ確認してみる

  • ip
$ docker-machine ip doc
192.168.99.101
  • env
$ docker-machine env doc
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.8.1, build master : 7f12e95 - Thu Aug 13 03:24:56 UTC 2015
Docker version 1.8.1, build d12ea79
docker@doc:~$

入れた

nginxをいれてみる

$ eval "$(docker-machine env doc)"

してdockerの接続先を変える

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

なにもない

imageの取得

$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx

2c49f83e0b13: Pull complete
4a5e6db8c069: Pull complete
08ecf065655b: Pull complete
ff0618bc0767: Pull complete
12a77b8bf89a: Pull complete
5dde53921c3f: Pull complete
a53219dc4d2f: Pull complete
8c7e9b6e3131: Pull complete
f9bff7d0d06e: Pull complete
3ac9cfbdf572: Pull complete
491aec45eaf8: Pull complete
cd3cf76a61ee: Pull complete
Digest: sha256:aaaaaaaaaaaabbbbbbbbbbbbb
Status: Downloaded newer image for nginx:lates
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
nginx               latest              cd3cf76a61ee        3 days ago          132.9 MB

できてる

$ docker run -i 80:80 -d nginx
$ docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                         NAMES
1d482c3d5542        nginx               "nginx -g 'daemon off"   26 seconds ago      Up 25 seconds       0.0.0.0:80->80/tcp, 443/tcp   mad_panini

ブラウザでアクセスしてみる

img

やった!