非常教程

Docker 17参考手册

机器 | Machine

docker-machine env

设置环境变量以指示docker应该对特定的计算机运行命令。

$ docker-machine env --help

Usage: docker-machine env [OPTIONS] [arg...]

Display the commands to set up the environment for the Docker client

Description:
   Argument is a machine name.

Options:

   --swarm	Display the Swarm config instead of the Docker daemon
   --shell 	Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh], default is sh/bash
   --unset, -u	Unset variables instead of setting them
   --no-proxy	Add machine IP to NO_PROXY environment variable

docker-machine env machinename打印出来export可以在子shell中运行的命令。跑动docker-machine env -u将打印unset可以逆转这种效果的命令。

$ env | grep DOCKER
$ eval "$(docker-machine env dev)"
$ env | grep DOCKER
DOCKER_HOST=tcp://192.168.99.101:2376
DOCKER_CERT_PATH=/Users/nathanleclaire/.docker/machines/.client
DOCKER_TLS_VERIFY=1
DOCKER_MACHINE_NAME=dev
$ # If you run a docker command, now it will run against that host.
$ eval "$(docker-machine env -u)"
$ env | grep DOCKER
$ # The environment variables have been unset.

上述输出旨在供弹bashzsh(如果你不知道哪个壳您正在使用,有一个很好的可能性,它是bash)。但是,这些并不是Docker Machine支持的唯一shell。Docker机器检测您的环境中可用的shell并列出它们。码头工人支持bashcmdpowershell,和emacs

如果你用fishSHELL环境变量正确设置为fish被发现了,docker-machine env name将以下列格式打印值:fish预期:

set -x DOCKER_TLS_VERIFY 1;
set -x DOCKER_CERT_PATH "/Users/nathanleclaire/.docker/machine/machines/overlay";
set -x DOCKER_HOST tcp://192.168.99.102:2376;
set -x DOCKER_MACHINE_NAME overlay
# Run this command to configure your shell:
# eval "$(docker-machine env overlay)"

如果您在Windows上并使用PowerShell cmd.exedocker-machine envDocker Machine现在应自动检测您的外壳。如果自动检测不起作用,您仍然可以使用--shell标志for 覆盖它docker-machine env

对于PowerShell:

$ docker-machine.exe env --shell powershell dev
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.99.101:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\captain\.docker\machine\machines\dev"
$Env:DOCKER_MACHINE_NAME = "dev"
# Run this command to configure your shell:
# docker-machine.exe env --shell=powershell dev | Invoke-Expression

cmd.exe*

$ docker-machine.exe env --shell cmd dev
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.99.101:2376
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
set DOCKER_MACHINE_NAME=dev
# Run this command to configure your shell: copy and paste the above values into your command prompt

提示:另请参阅如何在当前shell中取消设置环境变量。

将创建的机器排除在代理之外

env命令支持一个--no-proxy标志,它将确保创建的机器的IP地址被添加到NO_PROXY/ no_proxy环境变量。

docker-machine与互联网访问需要HTTP代理的网络环境中使用本地VM提供程序(例如virtualboxvmwarefusion)时,此功能很有用。

$ docker-machine env --no-proxy default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.104:2376"
export DOCKER_CERT_PATH="/Users/databus23/.docker/machine/certs"
export DOCKER_MACHINE_NAME="default"
export NO_PROXY="192.168.99.104"
# Run this command to configure your shell:
# eval "$(docker-machine env default)"

您可能还想HTTP_PROXY使用--engine-env标志来访问关于设置创建的守护进程的文档docker-machine create

机器,env,子命令

机器 | Machine相关

1.亚马逊网络服务(机器) | Amazon Web Services (Machine)
2.数字海洋(机器) | Digital Ocean (Machine)
3.docker机器活动 | docker-machine active
4.docker机器配置 | docker-machine config
5.docker机器创建 | docker-machine create
6.docker机器助手 | docker-machine help
7.docker机器检查 | docker-machine inspect
8.docker-machine ip
9.docker-machine kill
10.docker-machine ls
11.docker机器规定 | docker-machine provision
12.docker机器再生 | docker-machine regenerate-certs
13.docker机器重启 | docker-machine restart
14.docker-machine rm
15.docker-machine scp
16.docker-machine ssh
17.docker-machine start
18.docker-machine status
19.docker-machine stop
20.docker-machine upgrade
21.docker-machine url
22.驱动程序选项和操作系统默认值 | Driver options and operating system defaults (Machine)
23.驱动总览 | Drivers overview (Machine)
24.Exoscale (Machine)
25.通用 | Generic (Machine)
26.开始使用本地VM | Get started with a local VM (Machine)
27.谷歌电脑引擎 | Google Compute Engine (Machine)
28.IBM Softlayer (Machine)
29.安装机器 | Install Machine
30.机器 | Machine
31.机器CLI概述 | Machine CLI overview
32.机器命令行完成 | Machine command-line completion
33.机器概念和帮助 | Machine concepts and help
34.机器总览 | Machine overview
35.Microsoft Azure (Machine)
36.Microsoft Hyper-V (Machine)
37.从Boot2Docker迁移到Machine | Migrate from Boot2Docker to Machine
38.OpenStack (Machine)
39.Oracle VirtualBox (Machine)
40.配置AWS EC2实例(机器) | Provision AWS EC2 instances (Machine)
41.提供数字海洋 | Provision Digital Ocean Droplets (Machine)
42.在云中配置主机 | Provision hosts in the cloud (Machine)
43.Rackspace (Machine)
44.VMware Fusion (Machine)
45.VMware vCloud Air (Machine)
46.VMware vSphere (Machine)
Docker 17

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

主页 https://docker.com/
源码 https://github.com/docker/docker
版本 17
发布版本 17.06