Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Update CNAB-simple example to reflect the UX changes
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Briaud <caroline.briaud@docker.com>
  • Loading branch information
carolinebriaud committed Nov 19, 2019
1 parent 6c2b173 commit c46eab6
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Examples

This is a collection of [Docker App](../README.MD) examples. Most of them are fairly simple, and intended to illustrate various aspects of the Docker App product.
This is a collection of Docker App examples. Most of them are fairly simple, and intended to illustrate various aspects of the Docker App product.

### [Hello World: Starting example](hello-world)

Expand Down
134 changes: 95 additions & 39 deletions examples/cnab-simple/README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,116 @@
# Docker Application to CNAB
# Example: From Docker App to CNAB

### Requirements
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.
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.

* [Docker Desktop](https://www.docker.com/products/docker-desktop) with Kubernetes enabled or any other Kubernetes cluster
* Source code from this directory

### Examples
## App Definition

Show the details of the application with `inspect`
The App definition for this example is ready to use and can be found in the [hello.dockerapp](hello.dockerapp) directory in this folder.

```console
$ docker app inspect
hello 0.2.0

Maintained by: garethr <someone@example.com>
## App Image

Sample app for DockerCon EU 2018
Now we are going to build an App image from this App definition.

Service (1) Replicas Ports Image
----------- -------- ----- -----
hello 1 8765 hashicorp/http-echo:0.2.3
```shell
$ docker app build . -f hello.dockerapp -t myrepo/cnab-example:1.0.0
[+] Building 0.6s (6/6) FINISHED
(...) (Build output)
sha256:ee61121d6bff0266404cc0077599c1ef7130289fec721
```

Parameters (2) Value
-------------- -----
port 8765
text Hello DockerCon!
*Note that a `bundle.json` file has been created in the `/Users/username/.docker/app/bundles/docker.io/myrepo/cnab-example/_tags/1.0.0` directory.*

Open the open the `bundle.json` file in your favorite text editor and you'll see this is a [CNAB bundle](https://github.com/cnabio/cnab-spec).

Copy the `bundle.json`file to your working directory, next to the `hello.dockerapp` App definition.

```shell
$ tree
.
├── bundle.json
└── hello.dockerapp
├── docker-compose.yml
├── metadata.yml
└── parameters.yml
```

## Running App

### Run the app by passing App image

You can run this App using the `docker app run`command.

```shell
docker app run myrepo/cnab-example:1.0.0 --name mycnabexample
Creating network mycnabexample_default
Creating service mycnabexample_hello
App "mycnabexample" running on context "default"
```

Install the application:
Get the list of running Apps using the `docker app ls` command.

```console
$ docker app install
```shell
docker app ls
RUNNING APP APP NAME LAST ACTION RESULT CREATED MODIFIED REFERENCE
mycnabexample hello (0.2.0) install success 15 minutes ago 15 minutes ago docker.io/myrepo/cnab-example:1.0.0
```

Update the installation, demonstrating setting parameters:
Then remove the current running App.

```console
$ docker app update --set port=9876 --set text="hello DockerCon EU" hello
```shell
docker app rm mycnabexample
Removing service mycnabexample_hello
Removing network mycnabexample_default
```

Uninstall the application installation:
### Run the app by passing a `bundle.json` file

To demonstrate that Docker App is an implementation of [CNAB](https://cnab.io/), it is also possible to directly run the `bundle.json` file (or any other CNAB bundle) using the `--cnab-bundle-json` experimental flag.

*Note: To use this flag, you have to enable the experimental mode for the Docker CLI first.*

Open the `/Users/username/.docker/config.json` file in a text editor and change the `"experimental"` field to `"enabled"`.

```console
$ docker app uninstall hello
Run your app passing a `bundle.json` file

```shell
docker app run myrepo/cnab-example:1.0.0 --name mycnabexample --cnab-bundle-json bundle.json
Creating network mycnabexample_default
Creating service mycnabexample_hello
App "mycnabexample" running on context "default"
```

Demonstrate building a `bundle.json` for CNAB.

```console
$ docker app bundle
Invocation image "hello:0.2.0-invoc" successfully built
$ cat bundle.json
{
"name": "hello",
"version": "0.2.0",
"description": "Sample app for DockerCon EU 2018",
...
}
Get the list of running Apps using the `docker app ls` command.

```shell
docker app ls
RUNNING APP APP NAME LAST ACTION RESULT CREATED MODIFIED REFERENCE
mycnabexample hello (0.2.0) install success 15 minutes ago 15 minutes ago docker.io/myrepo/cnab-example:1.0.0
```

Inspect your running app using the `docker app inspect`command.

```shell
docker app inspect mycnabexample --pretty
Running App:
Name: titi
Created: 1 minute ago
Modified: 1 minute ago
Revision: 01DT28SRQZF12FN5YFQ36XCBYS
Last Action: install
Result: success
Ochestrator: swarm

App:
Name: hello
Version: 0.2.0

Parameters:
port: "8765"
text: Hello!

ID NAME MODE REPLICAS IMAGE PORTS
c21wxj9ts08y mycnabexample_hello replicated 1/1 hashicorp/http-echo *:8765->5678/tcp
```
4 changes: 2 additions & 2 deletions examples/cnab-simple/hello.dockerapp/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 0.2.0
name: hello
description: Sample app for DockerCon EU 2018
description: Hello world example
maintainers:
- name: garethr
- name: user
email: someone@example.com
2 changes: 1 addition & 1 deletion examples/cnab-simple/hello.dockerapp/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
port: 8765
text: Hello DockerCon!
text: Hello World!

0 comments on commit c46eab6

Please sign in to comment.