安装

linux

1
2
3
$ base=https://github.com/docker/machine/releases/download/v0.16.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
sudo install /tmp/docker-machine /usr/local/bin/docker-machine

可以直接把url打印出来,下载再安装

1
2
3
4
$ echo https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-$(uname -s)-$(uname -m)
https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-Linux-x86_64

$ sudo install docker-machine-Linux-x86_64 /usr/local/bin/docker-machine
创建机器
1
2
3
4
5
6
7
8
$ docker-machine create -d virtualbox node1

可以先下载
https://github.com/boot2docker/boot2docker/releases/download/v18.09.7/boot2docker.iso
$ mv boot2docker.iso $HOME/.docker/machine/cache/boot2docker.iso

再安装
$ docker-machine create node1 -d virtualbox --virtualbox-boot2docker-url=$HOME/.docker/machine/cache/boot2docker.iso
常用命令
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ docker-machine version
docker-machine version 0.16.0, build 702c267f

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
node1   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.0

$ docker-machine stop node1
Stopping "node1"...
Machine "node1" was stopped.

$ docker-machine start node1
Starting "node1"...
(node1) Check network to re-create if needed...
(node1) Waiting for an IP...
Machine "node1" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

$ eval $(docker-machine env node1)

$ docker-machine ssh node1

$ docker-machine ip node1
192.168.99.100 #主机IP