LoginSignup
7
8

More than 5 years have passed since last update.

docker-machine-xhyveを試す

Last updated at Posted at 2015-11-19

前書いたやつのコメントで教えていただいた,docker-machine-xhyveを試してみた.

前やったやつはgeneric driverで追加して管理するようにしただけだったので,うまく動けばこちらのほうが断然スジが良いですね.

goのお作法とかまったくわからないので適当なところはあるのですが,とりあえず書いてあるがままやってみます.

# /usr/local/bin にインストールされるぽいので,brewで入れたやつは外しておく
uraura@rosemary$ brew unlink docker-machine
Unlinking /usr/local/Cellar/docker-machine/0.5.0... 19 symlinks removed

uraura@rosemary$ ghq get nathanleclaire/machine
     clone https://github.com/nathanleclaire/machine -> /Users/uraura/src/github.com/nathanleclaire/machine
       git clone https://github.com/nathanleclaire/machine /Users/uraura/src/github.com/nathanleclaire/machine
Cloning into '/Users/uraura/src/github.com/nathanleclaire/machine'...
remote: Counting objects: 13386, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 13386 (delta 1), reused 0 (delta 0), pack-reused 13375
Receiving objects: 100% (13386/13386), 18.54 MiB | 1.22 MiB/s, done.
Resolving deltas: 100% (7154/7154), done.
Checking connectivity... done.

uraura@rosemary$ ghq look machine
        cd /Users/uraura/src/github.com/nathanleclaire/machine

uraura@rosemary$ make build
/bin/sh: go: command not found
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine  -tags "" -ldflags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine.go
/bin/sh: go: command not found
/bin/sh: go: command not found
make: *** [/Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine] Error 127

# そもそもgoが入ってなかった...
uraura@rosemary$ brew install go
==> Downloading https://homebrew.bintray.com/bottles/go-1.5.1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.5.1.el_capitan.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  https://golang.org/doc/code.html#GOPATH

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
🍺  /usr/local/Cellar/go/1.5.1: 5330 files, 273M

uraura@rosemary$ make build
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine  -tags "" -ldflags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine.go
cmd/machine.go:9:2: cannot find package "github.com/docker/machine/cli" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/cli (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:10:2: cannot find package "github.com/docker/machine/commands" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/commands (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:11:2: cannot find package "github.com/docker/machine/commands/mcndirs" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/commands/mcndirs (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:12:2: cannot find package "github.com/docker/machine/libmachine/log" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/libmachine/log (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:13:2: cannot find package "github.com/docker/machine/libmachine/mcnutils" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/libmachine/mcnutils (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:14:2: cannot find package "github.com/docker/machine/libmachine/ssh" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/libmachine/ssh (from $GOROOT)
        ($GOPATH not set)
cmd/machine.go:15:2: cannot find package "github.com/docker/machine/version" in any of:
        /usr/local/Cellar/go/1.5.1/libexec/src/github.com/docker/machine/version (from $GOROOT)
        ($GOPATH not set)
make: *** [/Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine] Error 1

# 何かが足りなそうだったので
uraura@rosemary$ ghq get docker/machine
     clone https://github.com/docker/machine -> /Users/uraura/src/github.com/docker/machine
       git clone https://github.com/docker/machine /Users/uraura/src/github.com/docker/machine
Cloning into '/Users/uraura/src/github.com/docker/machine'...
remote: Counting objects: 12498, done.
remote: Compressing objects: 100% (106/106), done.
remote: Total 12498 (delta 60), reused 0 (delta 0), pack-reused 12386
Receiving objects: 100% (12498/12498), 10.19 MiB | 1.49 MiB/s, done.
Resolving deltas: 100% (6574/6574), done.
Checking connectivity... done.

# あと適当にGOPATHをセット
uraura@rosemary$ export GOPATH=$HOME

uraura@rosemary$ make build
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine  -tags "" -ldflags "-X `go list ./v
ersion`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-amazonec2  -tags "" -ldflags
 "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-amazonec2.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-azure  -tags "" -ldflags "-X
 `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-azure.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-digitalocean  -tags "" -ldfl
ags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-digitalocean
.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-exoscale  -tags "" -ldflags
"-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-exoscale.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-generic  -tags "" -ldflags "
-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-generic.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-google  -tags "" -ldflags "-
X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-google.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-hyperv  -tags "" -ldflags "-
X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-hyperv.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-none  -tags "" -ldflags "-X
`go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-none.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-openstack  -tags "" -ldflags
 "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-openstack.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-rackspace  -tags "" -ldflags
 "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-rackspace.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-softlayer  -tags "" -ldflags
 "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-softlayer.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-virtualbox  -tags "" -ldflag
s "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-virtualbox.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-vmwarefusion  -tags "" -ldfl
ags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-vmwarefusion
.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-vmwarevcloudair  -tags "" -l
dflags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-vmwarevcl
oudair.go
go build -o /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine-driver-vmwarevsphere  -tags "" -ldf
lags "-X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` -w -s"  cmd/machine-driver-vmwarevsphe
re.go

uraura@rosemary$ make install
cp /Users/uraura/src/github.com/nathanleclaire/machine/bin/docker-machine /Users/uraura/src/github.com/nathanleclaire/
machine/bin/docker-machine-driver* /usr/local/bin

# 開発バージョンがインストールされた
uraura@rosemary$ docker-machine -v
docker-machine version 0.5.2-dev (HEAD)

uraura@rosemary$ ghq get zchee/xhyve-bindings
     clone https://github.com/zchee/xhyve-bindings -> /Users/uraura/src/github.com/zchee/xhyve-bindings
       git clone https://github.com/zchee/xhyve-bindings /Users/uraura/src/github.com/zchee/xhyve-bindings
Cloning into '/Users/uraura/src/github.com/zchee/xhyve-bindings'...
remote: Counting objects: 263, done.
remote: Total 263 (delta 0), reused 0 (delta 0), pack-reused 263
Receiving objects: 100% (263/263), 11.18 MiB | 1.83 MiB/s, done.
Resolving deltas: 100% (67/67), done.
Checking connectivity... done.

uraura@rosemary$ ghq look xhyve-bindings
        cd /Users/uraura/src/github.com/zchee/xhyve-bindings

uraura@rosemary$ make
rm -f ./main/goxhyve
rm -f /Users/uraura/bin/goxhyve
cd ./main && go build -o ./goxhyve

uraura@rosemary$ make install
rm -f ./main/goxhyve
rm -f /Users/uraura/bin/goxhyve
cd ./main && go build -o ./goxhyve
cp ./main/goxhyve /Users/uraura/bin/

uraura@rosemary$ brew tap zchee/libguestfs
==> Tapping zchee/libguestfs
Cloning into '/usr/local/Library/Taps/zchee/homebrew-libguestfs'...
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
Tapped 1 formula (25 files, 116K)

uraura@rosemary$ brew install libguestfs --with-go --devel --env=std
==> Installing libguestfs from zchee/homebrew-libguestfs
==> Installing dependencies for zchee/libguestfs/libguestfs: autoconf, automake, libtasn1, gmp, nettle, gnutls,
==> Installing zchee/libguestfs/libguestfs dependency: autoconf
...長すぎるので省略...
==> Summary
🍺  /usr/local/Cellar/libguestfs/1.31.7: 109 files, 14M, built in 7.3 minutes

uraura@rosemary$ ghq get zchee/docker-machine-xhyve
     clone https://github.com/zchee/docker-machine-xhyve -> /Users/uraura/src/github.com/zchee/docker-machine-xhyve
       git clone https://github.com/zchee/docker-machine-xhyve /Users/uraura/src/github.com/zchee/docker-machine-xhyve
Cloning into '/Users/uraura/src/github.com/zchee/docker-machine-xhyve'...
remote: Counting objects: 1213, done.
remote: Compressing objects: 100% (155/155), done.
remote: Total 1213 (delta 56), reused 0 (delta 0), pack-reused 1029
Receiving objects: 100% (1213/1213), 13.08 MiB | 2.06 MiB/s, done.
Resolving deltas: 100% (369/369), done.
Checking connectivity... done.

uraura@rosemary$ ghq look docker-machine-xhyve
        cd /Users/uraura/src/github.com/zchee/docker-machine-xhyve

uraura@rosemary$ make
Makefile:9: *** Please install godep: go get github.com/tools/godep.  Stop.

uraura@rosemary$ go get github.com/tools/godep

uraura@rosemary$ ls
Godeps/        TODO.md        imgs/          utils.go       vmnet/
Makefile       bin/           mk/            vendor/        xhyve.go
README.md      docs/          scripts/       version/       xhyve_test.go

uraura@rosemary$ make
==> Build docker-machine-xhyve ...
   /Users/uraura/bin/godep go build -o bin/docker-machine-driver-xhyve -ldflags  -w -s -X github.com/zchee/docker-mach
ine-xhyve/version.GitCommit=01ff106  github.com/zchee/docker-machine-xhyve/bin
==> Change docker-machine-xhyve binary owner and group to root:wheel
Password:

uraura@rosemary$ make install
==> Build docker-machine-xhyve ...
   /Users/uraura/bin/godep go build -o bin/docker-machine-driver-xhyve -ldflags  -w -s -X github.com/zchee/docker-mach
ine-xhyve/version.GitCommit=01ff106  github.com/zchee/docker-machine-xhyve/bin
==> Change docker-machine-xhyve binary owner and group to root:wheel
sudo cp -p ./bin/docker-machine-driver-xhyve /Users/uraura/bin/

ここまででインストール終わり

uraura@rosemary$ mkdir ~/work/docker-machine-xhyve

uraura@rosemary$ cd ~/work/docker-machine-xhyve/

uraura@rosemary$ docker-machine create -d xhyve
Driver "xhyve" not found. Do you have the plugin binary accessible in your PATH?

uraura@rosemary ls -l $HOME/bin
total 45616
-rwsr-xr-x  1 root    wheel   8.8M Nov 20 00:35 docker-machine-driver-xhyve*
-rwxr-xr-x  1 uraura  staff   9.4M Nov 20 00:34 godep*
-rwxr-xr-x  1 uraura  admin   4.1M Nov 20 00:22 goxhyve*

########################
# PATHに$HOME/binを追加 #
########################

uraura@rosemary$ docker-machine create -d xhyve xhyve-1st
Running pre-create checks...
Creating machine...
(xhyve-1st) Creating SSH key...
(xhyve-1st) Creating VM...
(xhyve-1st) Extracting vmlinuz64 and initrd.img from boot2docker.iso...
(xhyve-1st) Make a boot2docker userdata.tar key bundle...
(xhyve-1st) Fix file permission...
(xhyve-1st) Creating blank ext4 filesystem disk image...
(xhyve-1st) Generate UUID...
(xhyve-1st) Convert UUID to MAC address...
(xhyve-1st) Starting xhyve-1st...
(xhyve-1st) Waiting for VM to come online...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
To see how to connect Docker to this machine, run: docker-machine env xhyve-1st

uraura@rosemary$ docker-machine env xhyve-1st
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.64.47:2376"
export DOCKER_CERT_PATH="/Users/uraura/.docker/machine/machines/xhyve-1st"
export DOCKER_MACHINE_NAME="xhyve-1st"
# Run this command to configure your shell:
# eval "$(docker-machine env xhyve-1st)"

uraura@rosemary$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                        SWARM
dev         -        virtualbox   Stopped
xhyve-1st   -        xhyve        Running   tcp://192.168.64.47:2376

uraura@rosemary$ eval "$(docker-machine env xhyve-1st)"

uraura@rosemary$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
 Root Dir: /mnt/vda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.12-boot2docker
Operating System: Boot2Docker 1.9.0 (TCL 6.4); master : 16e4a2a - Tue Nov  3 19:49:22 UTC 2015
CPUs: 1
Total Memory: 996.3 MiB
Name: boot2docker
ID: GIYK:GYD3:JXR2:WKCT:CORE:WTDO:5433:K2GS:FSJU:T5E7:UZSX:WVBJ
Debug mode (server): true
File Descriptors: 12
Goroutines: 18
System Time: 2015-11-19T16:05:36.471981301Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/vda1/var/lib/docker
Labels:
 provider=xhyve

uraura@rosemary$ docker version
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.5.1
 Git commit:   f4bf5c7
 Built:        Thu Oct 15 09:34:18 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      linux/amd64

動いた!!

7
8
6

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
8