docker machine 使用说明

本文详细介绍了Docker Machine的使用方法,包括安装过程(在线与离线),命令操作如创建、管理云上或本地主机,以及如何使用各种子命令进行环境配置、主机状态检查等高级操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


docker machine 使用说明

 

官网:https://docs.docker.com/machine/overview/

 

 

*****************

应用

 

                    

                           

 

docker machine可以在虚拟主机上安装docker

使用docker-machine命令集中管理所有主机(启动、关闭、检查主机,升级docker等);

管理的主机可以是本地,也可以是云上的(Azure, AWS, or DigitalOcean)

 

 

*****************

docker machine 安装

 

*************

在线安装

 

官网:https://docs.docker.com/machine/install-machine/

 

linux安装

base=https://github.com/docker/machine/releases/download/v0.16.0 &&
  curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
  sudo mv /tmp/docker-machine /usr/local/bin/docker-machine &&
  chmod +x /usr/local/bin/docker-machine

说明:命令主要是下载release移动到指定位置(/usr/local/bin/docker-machine)、使docker-machine可执行

 

*************

离线安装

 

docker machine下载:https://github.com/docker/machine/releases

 

本地下载最新release,上传到虚拟机

将文件移动到指定位置(/usr/local/bin/docker-machine)

chmod +x docker-machine,使docker-machine 可执行

 

 

*****************

docker-machine 命令

 

命令格式:docker-machine  [options]  command

[root@centos ~]# docker-machine --help
Usage: docker-machine [OPTIONS] COMMAND [arg...]

Create and manage machines running Docker.

Version: 0.16.2, build bd45ab13

Author:
  Docker Machine Contributors - <https://github.com/docker/machine>

Options:
  --debug, -D					Enable debug mode
  --storage-path, -s "/root/.docker/machine"	Configures storage path [$MACHINE_STORAGE_PATH]
  --tls-ca-cert 				CA to verify remotes against [$MACHINE_TLS_CA_CERT]
  --tls-ca-key 					Private key to generate certificates [$MACHINE_TLS_CA_KEY]
  --tls-client-cert 				Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT]
  --tls-client-key 				Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY]
  --github-api-token 				Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN]
  --native-ssh					Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH]
  --bugsnag-api-token 				BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN]
  --help, -h					show help
  --version, -v					print the version
  
Commands:
  active		Print which machine is active
  config		Print the connection config for machine
  create		Create a machine
  env			Display the commands to set up the environment for the Docker client
  inspect		Inspect information about a machine
  ip			Get the IP address of a machine
  kill			Kill a machine
  ls			List machines
  provision		Re-provision existing machines
  regenerate-certs	Regenerate TLS Certificates for a machine
  restart		Restart a machine
  rm			Remove a machine
  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.
  start			Start a machine
  status		Get the status of a machine
  stop			Stop a machine
  upgrade		Upgrade a machine to the latest version of Docker
  url			Get the URL of a machine
  version		Show the Docker Machine version or a machine docker version
  help			Shows a list of commands or help for one command
  
Run 'docker-machine COMMAND --help' for more information on a command.

 

ls:列出所有主机

active:查看正在运行的主机

status:查看主机状态

 

config:查看主机的连接配置

env:设置主机环境变量

inspect:查看主机信息

upgrade:升级主机

provision:重新分配主机

regenerate-certs:重新生成证书

 

ip:查看主机ip

url:查看主机url

 

ssh:远程登陆主机

scp:远程文件复制

mount:文件挂载、卸载

 

create:创建主机

start:开启主机

restart:重启主机

kill:关闭主机

stop:停止主机

rm:删除主机

 

version:查看版本信息

help:命令帮助

 

****************

create 命令

 

generic 驱动:https://docs.docker.com/machine/drivers/generic/

 

使用generic驱动创建主机

docker-machine create \
  --driver generic \
  --generic-ip-address=203.0.113.81 \
  --generic-ssh-key ~/.ssh/id_rsa \
  vm

 

generic 环境变量

                           

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值