docker_practice/machine/usage.md

150 lines
4.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 使
Docker Machine
###
#### Virtualbox
使 `virtualbox` Docker test
```bash
$ docker-machine create -d virtualbox test
```
Docker
`--engine-opt dns=114.114.114.114` Docker DNS
`--engine-registry-mirror https://hub-mirror.c.163.com` Docker
`--virtualbox-memory 2048`
`--virtualbox-cpu-count 2` CPU
使 `docker-machine create --driver virtualbox --help`
#### macOS xhyve
`xhyve` GitHub: https://github.com/zchee/docker-machine-driver-xhyve
[`xhyve`](https://github.com/mist64/xhyve) 是 macOS 上轻量化的虚拟引擎,使用其创建的 Docker Machine 较 `VirtualBox` 驱动创建的运行效率要高。
```bash
$ brew install docker-machine-driver-xhyve
$ docker-machine create \
-d xhyve \
# --xhyve-boot2docker-url ~/.docker/machine/cache/boot2docker.iso \
--engine-opt dns=114.114.114.114 \
--engine-registry-mirror https://hub-mirror.c.163.com \
--xhyve-memory-size 2048 \
--xhyve-rawdisk \
--xhyve-cpu-count 2 \
xhyve
```
> `--xhyve-boot2docker-url ~/.docker/machine/cache/boot2docker.iso` GitHub ISO
使 `docker-machine create --driver xhyve --help`
#### Windows 10
Windows 10 Docker Desktop for Windows VirtualBox使 `virtualbox` Docker Machine使 `hyperv`
> `Hyper-V` **** 使 `--hyperv-virtual-switch=MY_SWITCH`
```bash
$ docker-machine create --driver hyperv --hyperv-virtual-switch=MY_SWITCH vm
```
使 `docker-machine create --driver hyperv --help`
### 使
```bash
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
test - virtualbox Running tcp://192.168.99.187:2376 v17.10.0-ce
```
`env`
```bash
$ docker-machine env test
```
test
`SSH`
```bash
$ docker-machine ssh test
docker@test:~$ docker --version
Docker version 17.10.0-ce, build f4ffd25
```
使 Docker
###
`-d`
* amazonec2
* azure
* digitalocean
* exoscale
* generic
* google
* hyperv
* none
* openstack
* rackspace
* softlayer
* virtualbox
* vmwarevcloudair
* vmwarefusion
* vmwarevsphere
###
[](https://github.com/docker/docker.github.io/blob/master/machine/AVAILABLE_DRIVER_PLUGINS.md) 查看
###
* `active` Docker
* `config`
* `create` Docker
* `env`
* `inspect`
* `ip`
* `kill`
* `ls`
* `provision`
* `regenerate-certs` TLS
* `restart`
* `rm`
* `ssh` SSH
* `scp`
* `mount`
* `start`
* `status`
* `stop`
* `upgrade` Docker
* `url` URL
* `version` docker-machine
* `help`
```bash
$ docker-machine COMMAND --help
```