目录搜索
ComposeAbout versions and upgrading (Compose)ASP.NET Core + SQL Server on Linux (Compose)CLI environment variables (Compose)Command-line completion (Compose)Compose(组成)Compose command-line reference(组合命令行参考)Control startup order (Compose)Django and PostgreSQL (Compose)Docker stacks and distributed application bundles (Compose)docker-compose build(docker-compose构建)docker-compose bundledocker-compose configdocker-compose createdocker-compose downdocker-compose eventsdocker-compose execdocker-compose helpdocker-compose imagesdocker-compose killdocker-compose logsdocker-compose pausedocker-compose portdocker-compose psdocker-compose pulldocker-compose pushdocker-compose restartdocker-compose rmdocker-compose rundocker-compose scaledocker-compose startdocker-compose stopdocker-compose topdocker-compose unpausedocker-compose upEnvironment file (Compose)Environment variables in ComposeExtend services in ComposeFrequently asked questions (Compose)Getting started (Compose)Install ComposeLink environment variables (deprecated) (Compose)Networking in ComposeOverview of Docker ComposeOverview of docker-compose CLIQuickstart: Compose and WordPressRails and PostgreSQL (Compose)Sample apps with ComposeUsing Compose in productionUsing Compose with SwarmEngine.NET Core application (Engine)About images, containers, and storage drivers (Engine)Add nodes to the swarm (Engine)Apply custom metadata (Engine)Apply rolling updates (Engine)apt-cacher-ngBest practices for writing Dockerfiles (Engine)Binaries (Engine)Bind container ports to the host (Engine)Breaking changes (Engine)Build your own bridge (Engine)Configure container DNS (Engine)Configure container DNS in user-defined networks (Engine)CouchDB (Engine)Create a base image (Engine)Create a swarm (Engine)Customize the docker0 bridge (Engine)Debian (Engine)Default bridge networkDelete the service (Engine)Deploy a service (Engine)Deploy services to a swarm (Engine)Deprecated Engine featuresDocker container networking (Engine)Docker overview (Engine)Docker run reference (Engine)Dockerfile reference (Engine)Dockerize an applicationDrain a node (Engine)EngineFAQ (Engine)Fedora (Engine)Get started (Engine)Get started with macvlan network driver (Engine)Get started with multi-host networking (Engine)How nodes work (Engine)How services work (Engine)Image management (Engine)Inspect the service (Engine)Install Docker (Engine)IPv6 with Docker (Engine)Join nodes to a swarm (Engine)Legacy container links (Engine)Lock your swarm (Engine)Manage nodes in a swarm (Engine)Manage sensitive data with Docker secrets (Engine)Manage swarm security with PKI (Engine)Manage swarm service networks (Engine)Migrate to Engine 1.10Optional Linux post-installation steps (Engine)Overview (Engine)PostgreSQL (Engine)Raft consensus in swarm mode (Engine)Riak (Engine)Run Docker Engine in swarm modeScale the service (Engine)SDKs (Engine)Select a storage driver (Engine)Set up for the tutorial (Engine)SSHd (Engine)Storage driver overview (Engine)Store service configuration data (Engine)Swarm administration guide (Engine)Swarm mode key concepts (Engine)Swarm mode overlay network security model (Engine)Swarm mode overview (Engine)Understand container communication (Engine)Use multi-stage builds (Engine)Use swarm mode routing mesh (Engine)Use the AUFS storage driver (Engine)Use the Btrfs storage driver (Engine)Use the Device mapper storage driver (Engine)Use the OverlayFS storage driver (Engine)Use the VFS storage driver (Engine)Use the ZFS storage driver (Engine)Engine: Admin GuideAmazon CloudWatch logs logging driver (Engine)Bind mounts (Engine)Collect Docker metrics with Prometheus (Engine)Configuring and running Docker (Engine)Configuring logging drivers (Engine)Control and configure Docker with systemd (Engine)ETW logging driver (Engine)Fluentd logging driver (Engine)Format command and log output (Engine)Google Cloud logging driver (Engine)Graylog Extended Format (GELF) logging driver (Engine)Journald logging driver (Engine)JSON File logging driver (Engine)Keep containers alive during daemon downtime (Engine)Limit a container's resources (Engine)Link via an ambassador container (Engine)Log tags for logging driver (Engine)Logentries logging driver (Engine)PowerShell DSC usage (Engine)Prune unused Docker objects (Engine)Run multiple services in a container (Engine)Runtime metrics (Engine)Splunk logging driver (Engine)Start containers automatically (Engine)Storage overview (Engine)Syslog logging driver (Engine)tmpfs mountsTroubleshoot volume problems (Engine)Use a logging driver plugin (Engine)Using Ansible (Engine)Using Chef (Engine)Using Puppet (Engine)View a container's logs (Engine)Volumes (Engine)Engine: CLIDaemon CLI reference (dockerd) (Engine)dockerdocker attachdocker builddocker checkpointdocker checkpoint createdocker checkpoint lsdocker checkpoint rmdocker commitdocker configdocker config createdocker config inspectdocker config lsdocker config rmdocker containerdocker container attachdocker container commitdocker container cpdocker container createdocker container diffdocker container execdocker container exportdocker container inspectdocker container killdocker container logsdocker container lsdocker container pausedocker container portdocker container prunedocker container renamedocker container restartdocker container rmdocker container rundocker container startdocker container statsdocker container stopdocker container topdocker container unpausedocker container updatedocker container waitdocker cpdocker createdocker deploydocker diffdocker eventsdocker execdocker exportdocker historydocker imagedocker image builddocker image historydocker image importdocker image inspectdocker image loaddocker image lsdocker image prunedocker image pulldocker image pushdocker image rmdocker image savedocker image tagdocker imagesdocker importdocker infodocker inspectdocker killdocker loaddocker logindocker logoutdocker logsdocker networkdocker network connectdocker network createdocker network disconnectdocker network inspectdocker network lsdocker network prunedocker network rmdocker nodedocker node demotedocker node inspectdocker node lsdocker node promotedocker node psdocker node rmdocker node updatedocker pausedocker plugindocker plugin createdocker plugin disabledocker plugin enabledocker plugin inspectdocker plugin installdocker plugin lsdocker plugin pushdocker plugin rmdocker plugin setdocker plugin upgradedocker portdocker psdocker pulldocker pushdocker renamedocker restartdocker rmdocker rmidocker rundocker savedocker searchdocker secretdocker secret createdocker secret inspectdocker secret lsdocker secret rmdocker servicedocker service createdocker service inspectdocker service logsdocker service lsdocker service psdocker service rmdocker service scaledocker service updatedocker stackdocker stack deploydocker stack lsdocker stack psdocker stack rmdocker stack servicesdocker startdocker statsdocker stopdocker swarmdocker swarm cadocker swarm initdocker swarm joindocker swarm join-tokendocker swarm leavedocker swarm unlockdocker swarm unlock-keydocker swarm updatedocker systemdocker system dfdocker system eventsdocker system infodocker system prunedocker tagdocker topdocker unpausedocker updatedocker versiondocker volumedocker volume createdocker volume inspectdocker volume lsdocker volume prunedocker volume rmdocker waitUse the Docker command line (Engine)Engine: ExtendAccess authorization plugin (Engine)Docker log driver pluginsDocker network driver plugins (Engine)Extending Engine with pluginsManaged plugin system (Engine)Plugin configuration (Engine)Plugins API (Engine)Volume plugins (Engine)Engine: SecurityAppArmor security profiles for Docker (Engine)Automation with content trust (Engine)Content trust in Docker (Engine)Delegations for content trust (Engine)Deploying Notary (Engine)Docker security (Engine)Docker security non-events (Engine)Isolate containers with a user namespace (Engine)Manage keys for content trust (Engine)Play in a content trust sandbox (Engine)Protect the Docker daemon socket (Engine)Seccomp security profiles for Docker (Engine)Secure EngineUse trusted imagesUsing certificates for repository client verification (Engine)Engine: TutorialsEngine tutorialsNetwork containers (Engine)Get StartedPart 1: OrientationPart 2: ContainersPart 3: ServicesPart 4: SwarmsPart 5: StacksPart 6: Deploy your appMachineAmazon Web Services (Machine)Digital Ocean (Machine)docker-machine activedocker-machine configdocker-machine createdocker-machine envdocker-machine helpdocker-machine inspectdocker-machine ipdocker-machine killdocker-machine lsdocker-machine provisiondocker-machine regenerate-certsdocker-machine restartdocker-machine rmdocker-machine scpdocker-machine sshdocker-machine startdocker-machine statusdocker-machine stopdocker-machine upgradedocker-machine urlDriver options and operating system defaults (Machine)Drivers overview (Machine)Exoscale (Machine)Generic (Machine)Get started with a local VM (Machine)Google Compute Engine (Machine)IBM Softlayer (Machine)Install MachineMachineMachine CLI overviewMachine command-line completionMachine concepts and helpMachine overviewMicrosoft Azure (Machine)Microsoft Hyper-V (Machine)Migrate from Boot2Docker to MachineOpenStack (Machine)Oracle VirtualBox (Machine)Provision AWS EC2 instances (Machine)Provision Digital Ocean Droplets (Machine)Provision hosts in the cloud (Machine)Rackspace (Machine)VMware Fusion (Machine)VMware vCloud Air (Machine)VMware vSphere (Machine)NotaryClient configuration (Notary)Common Server and signer configurations (Notary)Getting started with NotaryNotary changelogNotary configuration filesRunning a Notary serviceServer configuration (Notary)Signer configuration (Notary)Understand the service architecture (Notary)Use the Notary client
文字

创建一台机器。需要该--driver标志来指示应在哪个提供商(VirtualBox,DigitalOcean,AWS等)上创建机器,以及用于指示所创建机器的名称的参数。

$ docker-machine create --driver virtualbox dev
Creating CA: /home/username/.docker/machine/certs/ca.pem
Creating client certificate: /home/username/.docker/machine/certs/cert.pem
Image cache does not exist, creating it at /home/username/.docker/machine/cache...
No default boot2docker iso found locally, downloading the latest release...
Downloading https://github.com/boot2docker/boot2docker/releases/download/v1.6.2/boot2docker.
iso to /home/username/.docker/machine/cache/boot2docker.iso...
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...To see how to connect Docker to this machine, run: docker-machine env dev

访问帮助文本中特定于驱动程序的标志。

docker-machine create命令有一些适用于所有驱动程序的标志。这些主要控制用户可能希望定制的机器供应过程(包括创建Docker Swarm容器)的各个方面。

$ docker-machine create
Docker Machine Version: 0.5.0 (45e3688)Usage: docker-machine create [OPTIONS] [arg...]Create a machine.Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.Options:   --driver, -d "none"                                                                                  Driver to create machine with.   --engine-install-url "https://get.docker.com"                                                        Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL]   --engine-opt [--engine-opt option --engine-opt option]                                               Specify arbitrary flags to include with the created engine in the form flag=value   --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]     Specify insecure registries to allow with the created engine   --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]           Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR]   --engine-label [--engine-label option --engine-label option]                                         Specify labels for the created engine   --engine-storage-driver                                                                              Specify a storage driver to use with the engine   --engine-env [--engine-env option --engine-env option]                                               Specify environment variables to set in the engine   --swarm                                                                                              Configure Machine with Swarm   --swarm-image "swarm:latest"                                                                         Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]   --swarm-master                                                                                       Configure Machine to be a Swarm master   --swarm-discovery                                                                                    Discovery service to use with Swarm   --swarm-strategy "spread"                                                                            Define a default scheduling strategy for Swarm   --swarm-opt [--swarm-opt option --swarm-opt option]                                                  Define arbitrary flags for swarm   --swarm-host "tcp://0.0.0.0:3376"                                                                    ip/socket to listen on for Swarm master   --swarm-addr                                                                                         addr to advertise for Swarm (default: detect and use the machine IP)   --swarm-experimental                                                                                 Enable Swarm experimental features

此外,驱动程序可以指定机器可以接受的标志作为其插件代码的一部分。这些允许用户自定义创建的机器的特定于提供者的参数,例如size(--amazonec2-instance-type m1.medium),地理区域(--amazonec2-region us-west-1)等。

若要查看特定于提供程序的标志,只需传递--driver调用create帮助短信。

$ docker-machine create --driver virtualbox --help
Usage: docker-machine create [OPTIONS] [arg...]
Create a machine.Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.Options:   --driver, -d "none"                                                                                  Driver to create machine with.   --engine-env [--engine-env option --engine-env option]                                               Specify environment variables to set in the engine   --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]     Specify insecure registries to allow with the created engine   --engine-install-url "https://get.docker.com"                                                        Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL]   --engine-label [--engine-label option --engine-label option]                                         Specify labels for the created engine   --engine-opt [--engine-opt option --engine-opt option]                                               Specify arbitrary flags to include with the created engine in the form flag=value   --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]           Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR]   --engine-storage-driver                                                                              Specify a storage driver to use with the engine   --swarm                                                                                              Configure Machine with Swarm   --swarm-addr                                                                                         addr to advertise for Swarm (default: detect and use the machine IP)   --swarm-discovery                                                                                    Discovery service to use with Swarm   --swarm-experimental                                                                                 Enable Swarm experimental features   --swarm-host "tcp://0.0.0.0:3376"                                                                    ip/socket to listen on for Swarm master   --swarm-image "swarm:latest"                                                                         Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]   --swarm-master                                                                                       Configure Machine to be a Swarm master   --swarm-opt [--swarm-opt option --swarm-opt option]                                                  Define arbitrary flags for swarm   --swarm-strategy "spread"                                                                            Define a default scheduling strategy for Swarm   --virtualbox-boot2docker-url                                                                         The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL]   --virtualbox-cpu-count "1"                                                                           number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT]   --virtualbox-disk-size "20000"                                                                       Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]   --virtualbox-host-dns-resolver                                                                       Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER]   --virtualbox-dns-proxy                                                                               Proxy all DNS requests to the host [$VIRTUALBOX_DNS_PROXY]   --virtualbox-hostonly-cidr "192.168.99.1/24"                                                         Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR]   --virtualbox-hostonly-nicpromisc "deny"                                                              Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC]   --virtualbox-hostonly-nictype "82540EM"                                                              Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE]   --virtualbox-import-boot2docker-vm                                                                   The name of a Boot2Docker VM to import   --virtualbox-memory "1024"                                                                           Size of memory for host in MB [$VIRTUALBOX_MEMORY_SIZE]   --virtualbox-no-share                                                                                Disable the mount of your home directory

您可能会注意到一些标志也指定了它们与之关联的环境变量(位于该行的最左侧)。如果这些环境变量在docker-machine create被调用时被设置,Docker Machine将使用它们作为标志的默认值。

为创建的Docker引擎指定配置选项

作为创建过程的一部分,DockerMachine安装Docker并使用一些合理的默认设置对其进行配置。例如,它允许通过tcp与基于tls的加密进行连接,并且默认为存储驱动程序如果有的话。

在几种情况下,用户可能想要为创建的Docker引擎(也称为Docker 守护进程)自己设置选项。例如,他们可能希望允许使用守护进程的标志连接到他们正在运行的注册表--insecure-registry。Docker Machine支持通过create开头的命令标志为创建的引擎配置这些选项--engine

请注意,DockerMachine只是在守护进程上设置配置的参数,而不为您设置任何“依赖项”。例如,如果您指定创建的守护进程应该使用btrfs作为一个存储驱动程序,您仍然必须确保安装了适当的依赖项,已经创建了BTRFS文件系统,等等。

下面是一个示例用法:

$ docker-machine create -d virtualbox \    
--engine-label foo=bar \    
--engine-label spam=eggs \    
--engine-storage-driver overlay \    
--engine-insecure-registry registry.myco.com \
    foobarmachine

这将在VirtualBox中创建一个在本地运行的虚拟机,该虚拟机使用overlay存储后端,具有键值对。foo=barspam=eggs作为引擎上的标签,并允许从不安全的注册表推举/拉动位于registry.myco.com.您可以通过检查docker info*

$ eval $(docker-machine env foobarmachine)$ docker info
Containers: 0Images: 0Storage Driver: overlay...Name: foobarmachine...Labels:
 foo=bar
 spam=eggs
 provider=virtualbox

所支持的标志如下:

  • --engine-insecure-registry*具体说明不安全注册若要允许使用创建的引擎,请执行以下操作

  • --engine-registry-mirror*具体说明注册表镜像使用

  • --engine-label*具体说明标签对于创建的引擎

  • --engine-storage-driver*具体说明存储驱动程序与发动机一起使用

如果引擎支持多次指定标志(例如with --label),那么Docker Machine也是如此。

--engine-opt,可用于使用语法指定任意守护进程选项。--engine-opt flagname=value.例如,若要指定守护进程应使用8.8.8.8作为所有容器的dns服务器,并始终使用syslog日志驱动器您可以运行以下CREATE命令:

$ docker-machine create -d virtualbox \    
--engine-opt dns=8.8.8.8 \    
--engine-opt log-driver=syslog \
    gdns

另外,Docker Machine支持一个标志,--engine-env,它可以使用语法指定要在引擎内设置的任意环境变量。--engine-env name=value例如,若要指定引擎应使用example.com作为代理服务器,可以运行以下CREATE命令:

$ docker-machine create -d virtualbox \    
--engine-env HTTP_PROXY=http://example.com:8080 \    
--engine-env HTTPS_PROXY=https://example.com:8080 \   
--engine-env NO_PROXY=example2.com \
    proxbox

为所创建的计算机指定Docker群集选项

除了能够配置上面列出的Docker引擎选项之外,您还可以使用Machine指定应该如何配置所创建的Swarm主机。有一个--swarm-strategy标志,您可以使用它来指定Docker Swarm应该使用的调度策略(机器默认为spread策略)。还有一个通用--swarm-opt选项,它与上述--engine-opt选项类似,只是它指定了用于swarm manage命令(用于引导主节点)而不是基本命令的选项。您可以使用它来配置强大的用户可能感兴趣的功能,例如配置心跳间隔或Swarm过度提交资源的意愿。还有一个--swarm-experimental标志,允许你访问Docker Swarm中的实验性功能。

如果您不确定如何配置这些选项,最好不要指定配置。DockerMachine会为您选择合理的默认设置,您不必担心。

示例创建:

$ docker-machine create -d virtualbox \    
--swarm \    
--swarm-master \    
--swarm-discovery token://<token> \    
--swarm-strategy binpack \   
--swarm-opt heartbeat=5s \
    upbeat

这将将群集调度策略设置为“binpack”%28pack,在每个主机中尽可能严格地将其分配到容器中,而不是将它们分散到%29,“心跳”间隔为5秒。

预创建检查

由于许多驱动程序需要一定的条件才能成功执行创建(例如,应安装VirtualBox或提供的API凭据应该有效),Docker Machine会指定一个“预创建检查”在司机一级。

如果此预创建检查成功,Docker Machine将按正常方式继续创建.。如果预创建检查失败,DockerMachine进程将退出状态代码3,以指示非零退出的源是预创建检查失败。

上一篇:下一篇: