Commands: # 查看 docker-machine 所管理的全部宿主机 ls List machines # 查看哪台宿主机处于活动状态(当前主机的环境变量 DOCKER_HOST 指向某个宿主机,则该宿主机处于活动状态) active Print which machine is active # 查看特定宿主机的 SSH 连接配置信息(主要包括 CA、Cert、key、IP+端口) config Print the connection config for machine # 查看特定宿主机的 IP 地址 ip Get the IP address of a machine # 查看特定宿主机的详细信息 inspect Inspect information about a machine # 查看特定宿主机的 URL url Get the URL of a machine # 查看特定宿主机的状态 status Get the status of a machine # 显示相关命令用于设置 Docker Client 的指向(命令指向完成后,当前 Client 将指向特定宿主机) env Display the commands to set up the environment for the Docker client # 创建一个 Docker 宿主机 create Create a machine # 启动\停止\杀死\重启\移除一个宿主机 start Start a machine stop Stop a machine kill Kill a machine restart Restart a machine rm Remove a machine # SSH 远程登录特定宿主机 ssh Log into or run a command on a machine with SSH. # 宿主机之间拷贝文件 scp Copy files between machines # 挂载目录至特定宿主机 mount Mount or unmount a directory from a machine with SSHFS. # 重置特定宿主机 provision Re-provision existing machines # 为特定宿主机重新生成证书 regenerate-certs Regenerate TLS Certificates for a machine # 升级特定宿主机的 Docker 版本 upgrade Upgrade a machine to the latest version of Docker
在此,我们着重介绍 env 和 create 命令。
env
使用该命令后,将得到如下类似输出结果:
1 2 3 4 5 6
export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/home/hhd/.docker/machine/machines/1-machine" export DOCKER_MACHINE_NAME="1-machine" # Run this command to configure your shell: #eval $(docker-machine env 1-machine)