- 下載 Docker Machine 並安裝
docker@Docker:~$ curl -L https://github.com/docker/machine/releases/download/v0.13.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && \
chmod +x /tmp/docker-machine && \
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
- 建立一台有 Docker 環境的虛擬機器
docker@Docker:~$ docker-machine create -d=virtualbox vm
出現以下錯誤
錯誤 1
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
需安裝 VirtualBox
docker@Docker:~$ sudo apt-get install virtualbox
錯誤 2
Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"
需調整 VM 設定
點選運行 VM 右鍵 > "Settings…" > Processors => 勾選 Virtualize Intel VT-x/EPT or AMD-V/RVI
- 在 RUN 一次
docker@Docker:~$ docker-machine create -d=virtualbox vm
Running pre-create checks...
Creating machine...
(vm) Copying /home/docker/.docker/machine/cache/boot2docker.iso to /home/docker/.docker/machine/machines/vm/boot2docker.iso...
(vm) Creating VirtualBox VM...
(vm) Creating SSH key...
(vm) Starting the VM...
(vm) Check network to re-create if needed...
(vm) Found a new host-only adapter: "vboxnet0"
(vm) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env vm
- 查看 vm Machine 是否被建立
docker@Docker:~$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
vm - virtualbox Running tcp://192.168.99.100:2376 v18.01.0-ce
- 遠端到 vm 裡面
docker@Docker:~$ docker-machine ssh vm
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 18.01.0-ce, build HEAD : 0bb7bbd - Thu Jan 11 16:32:39 UTC 2018
Docker version 18.01.0-ce, build 03596f5
留言
張貼留言