Docker學習與實踐(八)
阿新 • • 發佈:2018-06-28
generic uname TP mon amd64 directory user onf 登陸 八、Docker Machine
1.安裝
[root@dockertest ~]# curl -L https://github.com/docker/machine/releases/download/v0.15.0/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine [root@dockertest ~]# chmod +x /tmp/docker-machine [root@dockertest ~]# cp /tmp/docker-machine /usr/local/bin/docker-machine [root@dockertest ~]# docker-machine -v docker-machine version 0.15.0, build b48dc28d
2.在遠程主機上安裝Docker
①遠程環境準備
a.新建一臺遠程主機並完成基礎配置
b.配置到遠程主機ssh免密登陸
②執行安裝
[root@dockertest ~]# docker-machine create -d generic > --generic-ip-address=192.168.10.128 > --generic-ssh-user=root > --generic-ssh-key ~/.ssh/id_rsa > machine1 Running pre-create checks... Creating machine... (machine1) Importing SSH key... 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 centos... 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 machine1 [root@dockertest ~]# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS machine1 - generic Running tcp://192.168.10.128:2376 v18.05.0-ce
③查看machine1的信息
[root@dockertest ~]# docker-machine env machine1 export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.10.128:2376" export DOCKER_CERT_PATH="/root/.docker/machine/machines/machine1" export DOCKER_MACHINE_NAME="machine1" # Run this command to configure your shell: # eval $(docker-machine env machine1)
這個命令讓本機的 Docker 客戶端可以與遠程的 Docker 服務器通信。
$ eval $( docker-machine env krdevdb)
④管理遠程的 Docker
[root@dockertest ~]# eval $(docker-machine env machine1) #使用
[root@dockertest ~]# docker version
Client:
Version: 18.02.0-ce
API version: 1.36
Go version: go1.9.3
Git commit: fc4de44
Built: Wed Feb 7 21:14:12 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.05.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: f150324
Built: Wed May 9 22:18:36 2018
OS/Arch: linux/amd64
Experimental: false
Docker學習與實踐(八)