direktori cari
Compose About 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 bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .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-ng Best 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 network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (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.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale 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 Guide Amazon 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 mounts Troubleshoot 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: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor 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 Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver 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 Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (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) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
watak

创建一台机器。需要该--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,以指示非零退出的源是预创建检查失败。

Artikel sebelumnya: Artikel seterusnya: