github.com/docker/app@v0.9.1-beta3.0.20210611140623-a48f773ab002/README.md (about)

     1  ### :warning: Deprecation Notice: This project and repository is now deprecated and is no longer in active development, see [the related roadmap issue](https://github.com/docker/roadmap/issues/209). If you'd like to continue using CNAB for packaging your applications, check out [Porter](https://porter.sh).
     2  
     3  # Docker App
     4  
     5  Docker App is a Cloud Native application packaging framework with which developers and devops can  build, share, and run a set of microservices as a single entity. Docker Apps are based on the [Compose format](https://docs.docker.com/compose/compose-file/), which permits [docker-compose](https://github.com/docker/compose) users to easily share their Compose-based multiservice applications via container registries. By leveraging containers, Docker App makes it possible to easily change parts of the application and to share the application through container registries.
     6  
     7  ### Table of Contents
     8  - **[What are the benefits offered by Docker App?](#what-are-the-benefits-offered-by-docker-app)**
     9  - **[How does Docker App work?](#how-does-docker-app-work)**
    10  - **[Using Docker App](#using-docker-app)**
    11      * **[Writing an App definition](#writing-an-app-definition)**
    12      * **[Building an App image](#building-an-app-image)**
    13      * **[Sharing the App on the Hub](#sharing-the-app-on-the-hub)**
    14      * **[Running the App](#running-the-app)**
    15  - **[Example](#example)**
    16      * **[App definition](#app-definition)**
    17      * **[Using parameters](#using-parameters)**
    18      * **[Building an App image](#building-an-app-image)**
    19      * **[Sharing and running the App](#sharing-and-running-the-app)**
    20  - **[CNAB](#cnab)**
    21  - **[Installation](#installation)**
    22      * **[Linux or macOS](#linux-or-macos)**
    23      * **[Windows](#windows)**
    24  - **[Next steps](#next-steps)**
    25  
    26  ## What are the benefits offered by Docker App?
    27  
    28  * Simple management of Docker Apps across different teams and between different environments (Development/QA/Staging/Production)
    29  * Easy sharing of multi-service applications to container registries (e.g., [Docker Hub](https://hub.docker.com/) or [Docker Trusted Registry](https://docs.docker.com/ee/dtr/))
    30  * Having a clear separation of parameters to be modified at runtime 
    31  * Support for multiple orchestrators (Swarm or Kubernetes)
    32  * Provides the very same UX flow as the one for Docker images
    33  * Implements the [CNAB](https://cnab.io) industry standard
    34  * Offers full support for Docker Contexts
    35  
    36  ## How does Docker App work?
    37  
    38  The Docker App workflow is quite similar to the Docker image workflow. From an App definition, you can build an App image, share it on Docker Hub, and run your App on an orchestrator.
    39  
    40  ![Image showing Docker CLI command flow](DockerAppCLIcommands.png)
    41  
    42  ## Using Docker App
    43  
    44  Four primary steps comprise the Docker App process:
    45  1. Writing an App Definition
    46  1. Building an App Image
    47  1. Sharing the App on the Hub (optional)
    48  1. Running the App
    49  
    50  ### Writing an App definition
    51  
    52  The first step in using Docker App is to write the App definition. This definition can be created (1) from an existing [Compose file](https://docs.docker.com/compose/compose-file/) using the `docker app init` command (2) via  a template from the [Application Designer](https://docs.docker.com/ee/desktop/app-designer/), or (3) from scratch. 
    53  
    54  The App definition is a .dockerapp folder that contains three distinct pieces: metadata, a service list, and the parameters. 
    55  
    56  | File | Description |
    57  | :------------ | :------------ |
    58  | metadata.yml | metadata including the App name and version |
    59  | docker-compose.yml | Service list defined in a Compose file |
    60  | parameters.yml | Parameters that can be changed when running the App |
    61  
    62  *Note: To store additional files in Docker Apps, such as `prod.yml`, `test.yml` or other config files, you need only to add these files to the *.dockerapp directory. All files will be packaged into the App image through the use of the `docker app build`  command.*
    63  
    64  ### Building an App image
    65  
    66  Once the App definition is written, the next step is to build the App image from the App definition using the `docker app build` command. With this command you can tag your App image, set build-time variables, or make the build quiet. 
    67  
    68  Note that service images inside of an App image are immutable, meaning that the App version ties to a fixed list of service images (i.e., updating the images inside of a Docker App requires rebuilding the App image). This makes deploying applications more deterministic.
    69  
    70  ### Sharing the App on the Hub
    71  
    72  You can push any App image already built or pulled to Docker Hub (or any [OCI compliant registry](https://www.opencontainers.org)) using the `docker app push` command. You can also pull App images from any OCI compliant registry using the `docker app pull` command.
    73  
    74  When pushing an App image, all the service images used by the application are pushed at the same time inside a single entity. The version of each service image is resolved at build time from its tag.
    75  
    76  ### Running the App
    77  
    78  The final Docker App step is to actually run your App using the `docker app run` command. You can either pick up an App image from Docker Hub or one that you built locally and deploy it to Swarm or Kubernetes.
    79  
    80  ## Example
    81  
    82  Using the [hello-world](./examples/hello-world) application example, we are going to build, share, and run a Docker App that launches an HTTP server that prints the text variable value when hit on the configured port. 
    83  
    84  *Note: Before starting, confirm that the Docker App CLI plugin is [installed](#installation) on your machine*
    85  
    86  ### App definition
    87  
    88  First, create an App definition from an existing Compose file.
    89  
    90  Create a `docker-compose.yml` file that has the following content: 
    91  
    92  ```yaml
    93  version: '3.6'
    94  services:
    95    hello:
    96      image: hashicorp/http-echo
    97      command: ["-text", "hello world"]
    98      ports:
    99        - 5678:5678
   100  ```
   101  
   102  Next, create an App definition using the `docker app init` command:
   103  
   104  ```shell
   105  $ docker app init --compose-file docker-compose.yml hello
   106  Created "hello.dockerapp"
   107  $ tree
   108  .
   109  ├── docker-compose.yml
   110  ├── hello.dockerapp
   111      ├── docker-compose.yml
   112      ├── metadata.yml
   113      └── parameters.yml
   114  ```
   115  
   116  A new folder named `hello.dockerapp` now exists, which contains three YAML documents:
   117  * metadata
   118  * a Compose file
   119  * parameters for your application to be used at runtime
   120  
   121  The `metadata.yml` file should display as follows:
   122  
   123  ```yaml
   124  version: 0.1.0
   125  name: hello
   126  description: A simple text server
   127  maintainers:
   128  - name: yourusername
   129    email:
   130  ```
   131  
   132  The Compose file is the one that was passed in parameters. Thus, if you open `parameters.yml` you will notice that it is empty, as the Compose file isn’t using any variable.
   133  
   134  ### Using parameters
   135  
   136  Edit the `docker-compose.yml` file in the `hello.dockerapp` directory to add some variables:
   137  
   138  ```yaml
   139  version: '3.6'
   140  services:
   141    hello:
   142      image: hashicorp/http-echo
   143      command: ["-text", "${text}"]
   144      ports:
   145        - ${port}:5678
   146  ```
   147  
   148  Next, define the default values for the App in the `parameters.yml` file:
   149  
   150  ```yaml
   151  port: 5678
   152  text: hello development
   153  ```
   154  
   155  ### Building an App image
   156  
   157  Next, build an App image:
   158  
   159  ```shell
   160  $ docker app build . -f hello.dockerapp -t myrepo/hello:0.1.0
   161  [+] Building 0.7s (6/6) FINISHED
   162  (...) (Build output)
   163  sha256:4a492748ae55170daadd1ddfff4db30e0ef3d38bf0f57a913512caa323e140de
   164  ```                                                                              
   165  
   166  At this point, an App image with the `myrepo/hello:1.0.1` tag has been built from the `hello.dockerapp` App definition. This immutable App image includes all the service images at fixed versions that you can run or share.
   167  
   168  ### Sharing and running the App
   169  
   170  To share your App image, push it to a container registry.
   171  
   172  ```shell
   173  $ docker app push myrepo/hello:0.1.0
   174  ```  
   175  
   176  Now run your App:
   177  
   178  ```shell
   179  $ docker app run myrepo/hello:0.1.0 
   180  ``` 
   181  
   182  You can specify the Docker endpoint where an application is installed using a context. By default, your App will run on the currently active context. You can select another context with the `docker context use` command, and the `docker app run` command will thereafter run your app on this particular context. 
   183  
   184  Whenever you define such a context, the installer image will run in the default context (i.e., on local host). You can then use the `--installer-context` to target another context to run the installer image.
   185  
   186  ```shell
   187  $ docker context create remote --description "remote cluster" --docker host=tcp://<remote-ip>:<remote-port>
   188  Successfully created context "remote"
   189  
   190  $ docker context ls
   191  NAME                DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT                ORCHESTRATOR
   192  default *           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   https://localhost:6443 (default)   swarm
   193  remote              remote cluster                            tcp://<remote-ip>:<remote-port>
   194  
   195  $ docker context use remote
   196  $ docker app run myrepo/hello:0.1.0
   197  ``` 
   198  
   199  ## CNAB
   200  
   201  Docker Apps are Docker’s implementation of the industry standard Cloud Native Application Bundle (CNAB). [CNAB](https://cnab.io/) is an industry specification put in place to facilitate the bundling, sharing, installing and managing of cloud-native apps that are not only made up of containers but also from such things as hosted databases, functions, etc. 
   202  Docker App is designed to abstract as many CNAB specifics as possible, to provide users with a tool that is easy to use while alleviating the need to bother with the CNAB specification.
   203  
   204  ## Installation
   205  
   206  Docker App is a *command line* plugin (not be confused with *docker engine plugins*) that extends the `docker` command with `app` sub-commands. It requires [Docker CLI](https://download.docker.com/) 19.03.0 or later, with experimental features enabled. Either set environment variable `DOCKER_CLI_EXPERIMENTAL=enabled` or update your [docker CLI configuration](https://docs.docker.com/engine/reference/commandline/cli/#experimental-features).
   207  
   208  *Note: The* `docker plugin install` *command cannot be used to install Docker-app.*
   209  
   210  ### Linux or macOS
   211  
   212  Download your OS tarball:
   213  ```shell
   214  export OSTYPE="$(uname | tr A-Z a-z)"
   215  curl -fsSL --output "/tmp/docker-app-${OSTYPE}.tar.gz" "https://github.com/docker/app/releases/download/v0.8.0/docker-app-${OSTYPE}.tar.gz"
   216  tar xf "/tmp/docker-app-${OSTYPE}.tar.gz" -C /tmp/
   217  ```
   218  
   219  Install as a Docker CLI plugin:
   220  ```shell
   221  mkdir -p ~/.docker/cli-plugins && cp "/tmp/docker-app-plugin-${OSTYPE}" ~/.docker/cli-plugins/docker-app
   222  ```
   223  
   224  ### Windows
   225  
   226  Download the Windows tarball:
   227  ```powershell
   228  Invoke-WebRequest -Uri https://github.com/docker/app/releases/download/v0.8.0/docker-app-windows.tar.gz -OutFile docker-app.tar.gz -UseBasicParsing
   229  tar xf "docker-app.tar.gz"
   230  ```
   231  
   232  Install as a Docker CLI plugin:
   233  ```powershell
   234  New-Item -ItemType Directory -Path ~/.docker/cli-plugins -ErrorAction SilentlyContinue
   235  cp docker-app-plugin-windows.exe ~/.docker/cli-plugins/docker-app.exe
   236  ```
   237  
   238  ## Next steps
   239  
   240  If you're interested in contributing to the project, jump to
   241  [BUILDING.md](BUILDING.md) and [CONTRIBUTING.md](CONTRIBUTING.md).
   242  
   243  Further examples are available in the [examples](https://github.com/docker/app/blob/master/examples) directory.