github.com/portworx/docker@v1.12.1/experimental/docker-stacks-and-bundles.md (about)

     1  # Docker Stacks and Distributed Application Bundles
     2  
     3  ## Overview
     4  
     5  Docker Stacks and Distributed Application Bundles are experimental features
     6  introduced in Docker 1.12 and Docker Compose 1.8, alongside the concept of
     7  swarm mode, and Nodes and Services in the Engine API.
     8  
     9  A Dockerfile can be built into an image, and containers can be created from
    10  that image. Similarly, a docker-compose.yml can be built into a **distributed
    11  application bundle**, and **stacks** can be created from that bundle. In that
    12  sense, the bundle is a multi-services distributable image format.
    13  
    14  As of Docker 1.12 and Compose 1.8, the features are experimental. Neither
    15  Docker Engine nor the Docker Registry support distribution of bundles.
    16  
    17  ## Producing a bundle
    18  
    19  The easiest way to produce a bundle is to generate it using `docker-compose`
    20  from an existing `docker-compose.yml`. Of course, that's just *one* possible way
    21  to proceed, in the same way that `docker build` isn't the only way to produce a
    22  Docker image.
    23  
    24  From `docker-compose`:
    25  
    26  ```bash
    27  $ docker-compose bundle
    28  WARNING: Unsupported key 'network_mode' in services.nsqd - ignoring
    29  WARNING: Unsupported key 'links' in services.nsqd - ignoring
    30  WARNING: Unsupported key 'volumes' in services.nsqd - ignoring
    31  [...]
    32  Wrote bundle to vossibility-stack.dab
    33  ```
    34  
    35  ## Creating a stack from a bundle
    36  
    37  A stack is created using the `docker deploy` command:
    38  
    39  ```bash
    40  # docker deploy --help
    41  
    42  Usage:  docker deploy [OPTIONS] STACK
    43  
    44  Create and update a stack
    45  
    46  Options:
    47        --file   string        Path to a Distributed Application Bundle file (Default: STACK.dab)
    48        --help                 Print usage
    49        --with-registry-auth   Send registry authentication details to Swarm agents
    50  ```
    51  
    52  Let's deploy the stack created before:
    53  
    54  ```bash
    55  # docker deploy vossibility-stack
    56  Loading bundle from vossibility-stack.dab
    57  Creating service vossibility-stack_elasticsearch
    58  Creating service vossibility-stack_kibana
    59  Creating service vossibility-stack_logstash
    60  Creating service vossibility-stack_lookupd
    61  Creating service vossibility-stack_nsqd
    62  Creating service vossibility-stack_vossibility-collector
    63  ```
    64  
    65  We can verify that services were correctly created:
    66  
    67  ```bash
    68  # docker service ls
    69  ID            NAME                                     REPLICAS  IMAGE
    70  COMMAND
    71  29bv0vnlm903  vossibility-stack_lookupd                1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662 /nsqlookupd
    72  4awt47624qwh  vossibility-stack_nsqd                   1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662 /nsqd --data-path=/data --lookupd-tcp-address=lookupd:4160
    73  4tjx9biia6fs  vossibility-stack_elasticsearch          1 elasticsearch@sha256:12ac7c6af55d001f71800b83ba91a04f716e58d82e748fa6e5a7359eed2301aa
    74  7563uuzr9eys  vossibility-stack_kibana                 1 kibana@sha256:6995a2d25709a62694a937b8a529ff36da92ebee74bafd7bf00e6caf6db2eb03
    75  9gc5m4met4he  vossibility-stack_logstash               1 logstash@sha256:2dc8bddd1bb4a5a34e8ebaf73749f6413c101b2edef6617f2f7713926d2141fe logstash -f /etc/logstash/conf.d/logstash.conf
    76  axqh55ipl40h  vossibility-stack_vossibility-collector  1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba --config /config/config.toml --debug
    77  ```
    78  
    79  ## Managing stacks
    80  
    81  Stacks are managed using the `docker stack` command:
    82  
    83  ```bash
    84  # docker stack --help
    85  
    86  Usage:  docker stack COMMAND
    87  
    88  Manage Docker stacks
    89  
    90  Options:
    91        --help   Print usage
    92  
    93  Commands:
    94    config      Print the stack configuration
    95    deploy      Create and update a stack
    96    rm          Remove the stack
    97    tasks       List the tasks in the stack
    98  
    99  Run 'docker stack COMMAND --help' for more information on a command.
   100  ```
   101  
   102  ## Bundle file format
   103  
   104  Distributed application bundles are described in a JSON format. When bundles
   105  are persisted as files, the file extension is `.dab` (Docker 1.12RC2 tools use
   106  `.dsb` for the file extension—this will be updated in the next release client).
   107  
   108  A bundle has two top-level fields: `version` and `services`. The version used
   109  by Docker 1.12 tools is `0.1`.
   110  
   111  `services` in the bundle are the services that comprise the app. They
   112  correspond to the new `Service` object introduced in the 1.12 Docker Engine API.
   113  
   114  A service has the following fields:
   115  
   116  <dl>
   117      <dt>
   118          Image (required) <code>string</code>
   119      </dt>
   120      <dd>
   121          The image that the service will run. Docker images should be referenced
   122          with full content hash to fully specify the deployment artifact for the
   123          service. Example:
   124          <code>postgres@sha256:f76245b04ddbcebab5bb6c28e76947f49222c99fec4aadb0bb
   125          1c24821a 9e83ef</code>
   126      </dd>
   127      <dt>
   128          Command <code>[]string</code>
   129      </dt>
   130      <dd>
   131          Command to run in service containers.
   132      </dd>
   133      <dt>
   134          Args <code>[]string</code>
   135      </dt>
   136      <dd>
   137          Arguments passed to the service containers.
   138      </dd>
   139      <dt>
   140          Env <code>[]string</code>
   141      </dt>
   142      <dd>
   143          Environment variables.
   144      </dd>
   145      <dt>
   146          Labels <code>map[string]string</code>
   147      </dt>
   148      <dd>
   149          Labels used for setting meta data on services.
   150      </dd>
   151      <dt>
   152          Ports <code>[]Port</code>
   153      </dt>
   154      <dd>
   155          Service ports (composed of <code>Port</code> (<code>int</code>) and
   156          <code>Protocol</code> (<code>string</code>). A service description can
   157          only specify the container port to be exposed. These ports can be
   158          mapped on runtime hosts at the operator's discretion.
   159      </dd>
   160  
   161      <dt>
   162          WorkingDir <code>string</code>
   163      </dt>
   164      <dd>
   165          Working directory inside the service containers.
   166      </dd>
   167  
   168      <dt>
   169          User <code>string</code>
   170      </dt>
   171      <dd>
   172          Username or UID (format: <code>&lt;name|uid&gt;[:&lt;group|gid&gt;]</code>).
   173      </dd>
   174  
   175      <dt>
   176          Networks <code>[]string</code>
   177      </dt>
   178      <dd>
   179          Networks that the service containers should be connected to. An entity
   180          deploying a bundle should create networks as needed.
   181      </dd>
   182  </dl>
   183