Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 0c682c3

Browse files
Update CNAB-simple example to reflect the UX changes
Signed-off-by: Caroline Briaud <[email protected]>
1 parent 6c2b173 commit 0c682c3

File tree

4 files changed

+110
-43
lines changed

4 files changed

+110
-43
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Examples
22

3-
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.
3+
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.
44

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

examples/cnab-simple/README.md

Lines changed: 106 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,127 @@
1-
# Docker Application to CNAB
1+
# Example: From Docker App to CNAB
22

3-
### Requirements
3+
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.
44

5-
* [Docker Desktop](https://www.docker.com/products/docker-desktop) with Kubernetes enabled or any other Kubernetes cluster
6-
* Source code from this directory
5+
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.
76

8-
### Examples
7+
This example will demonstrate that Docker App is actually leveraging CNAB. To learn more about CNAB, you can refer to the [CNAB specification](https://github.com/cnabio/cnab-spec).
98

10-
Show the details of the application with `inspect`
119

12-
```console
13-
$ docker app inspect
14-
hello 0.2.0
10+
## App Definition
1511

16-
Maintained by: garethr <someone@example.com>
12+
The App definition for this example is ready to use and can be found in the [hello.dockerapp](hello.dockerapp) directory in this folder.
1713

18-
Sample app for DockerCon EU 2018
1914

20-
Service (1) Replicas Ports Image
21-
----------- -------- ----- -----
22-
hello 1 8765 hashicorp/http-echo:0.2.3
15+
## App Image
2316

24-
Parameters (2) Value
25-
-------------- -----
26-
port 8765
27-
text Hello DockerCon!
17+
Now we are going to build an App image from this App definition.
18+
19+
```shell
20+
$ docker app build . -f hello.dockerapp -t myrepo/cnab-example:1.0.0
21+
[+] Building 0.6s (6/6) FINISHED
22+
(...) (Build output)
23+
sha256:ee61121d6bff0266404cc0077599c1ef7130289fec721
24+
```
25+
26+
*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.*
27+
28+
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).
29+
30+
Copy the `bundle.json`file to your working directory, next to the `hello.dockerapp` App definition.
31+
32+
```shell
33+
$ tree
34+
.
35+
├── bundle.json
36+
└── hello.dockerapp
37+
├── docker-compose.yml
38+
├── metadata.yml
39+
└── parameters.yml
2840
```
2941

30-
Install the application:
42+
## Running App
3143

32-
```console
33-
$ docker app install
44+
### Run the App from an App image
45+
46+
You can run this App using the `docker app run`command.
47+
48+
```shell
49+
$ docker app run myrepo/cnab-example:1.0.0 --name mycnabexample
50+
Creating network mycnabexample_default
51+
Creating service mycnabexample_hello
52+
App "mycnabexample" running on context "default"
3453
```
3554

36-
Update the installation, demonstrating setting parameters:
55+
Get the list of running Apps using the `docker app ls` command.
3756

38-
```console
39-
$ docker app update --set port=9876 --set text="hello DockerCon EU" hello
57+
```shell
58+
$ docker app ls
59+
RUNNING APP APP NAME LAST ACTION RESULT CREATED MODIFIED REFERENCE
60+
mycnabexample hello (0.2.0) install success 15 minutes ago 15 minutes ago docker.io/myrepo/cnab-example:1.0.0
4061
```
4162

42-
Uninstall the application installation:
63+
Then remove the current running App.
4364

44-
```console
45-
$ docker app uninstall hello
65+
```shell
66+
$ docker app rm mycnabexample
67+
Removing service mycnabexample_hello
68+
Removing network mycnabexample_default
4669
```
4770

48-
Demonstrate building a `bundle.json` for CNAB.
49-
50-
```console
51-
$ docker app bundle
52-
Invocation image "hello:0.2.0-invoc" successfully built
53-
$ cat bundle.json
54-
{
55-
"name": "hello",
56-
"version": "0.2.0",
57-
"description": "Sample app for DockerCon EU 2018",
58-
...
59-
}
71+
### Run the App from a CNAB bundle
72+
73+
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.
74+
75+
*Note: To use this flag, you have to enable the experimental mode for the Docker CLI first.*
76+
77+
Open the `/Users/username/.docker/config.json` file in a text editor and change the `"experimental"` field to `"enabled"`.
78+
79+
Run your app passing a `bundle.json` file.
80+
81+
```shell
82+
$ docker app run myrepo/cnab-example:1.0.0 --name mycnabexample --cnab-bundle-json bundle.json
83+
Creating network mycnabexample_default
84+
Creating service mycnabexample_hello
85+
App "mycnabexample" running on context "default"
86+
```
87+
88+
Get the list of running Apps using the `docker app ls` command.
89+
90+
```shell
91+
$ docker app ls
92+
RUNNING APP APP NAME LAST ACTION RESULT CREATED MODIFIED REFERENCE
93+
mycnabexample hello (0.2.0) install success 15 minutes ago 15 minutes ago docker.io/myrepo/cnab-example:1.0.0
6094
```
95+
96+
Inspect your running app using the `docker app inspect`command.
97+
98+
```shell
99+
$ docker app inspect mycnabexample --pretty
100+
Running App:
101+
Name: titi
102+
Created: 1 minute ago
103+
Modified: 1 minute ago
104+
Revision: 01DT28SRQZF12FN5YFQ36XCBYS
105+
Last Action: install
106+
Result: success
107+
Ochestrator: swarm
108+
109+
App:
110+
Name: hello
111+
Version: 0.2.0
112+
113+
Parameters:
114+
port: "8765"
115+
text: Hello!
116+
117+
ID NAME MODE REPLICAS IMAGE PORTS
118+
c21wxj9ts08y mycnabexample_hello replicated 1/1 hashicorp/http-echo *:8765->5678/tcp
119+
```
120+
121+
Finally, remove the current running App.
122+
123+
```shell
124+
$ docker app rm mycnabexample
125+
Removing service mycnabexample_hello
126+
Removing network mycnabexample_default
127+
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 0.2.0
22
name: hello
3-
description: Sample app for DockerCon EU 2018
3+
description: Hello world example
44
maintainers:
5-
- name: garethr
5+
- name: user
66
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
port: 8765
2-
text: Hello DockerCon!
2+
text: Hello World!

0 commit comments

Comments
 (0)