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

Commit f38c337

Browse files
Merge pull request #761 from carolinebriaud/fix-coins
Update dockercoins README to match new UX
2 parents b621499 + 578c58b commit f38c337

File tree

1 file changed

+165
-7
lines changed

1 file changed

+165
-7
lines changed

examples/dockercoins/README.md

Lines changed: 165 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,169 @@
1-
# dockercoins
1+
# Example: Dockercoins
22

3-
This is the demo application originally used in Jérôme Petazzoni's [orchestration workshop](https://github.com/jpetazzo/container.training).
3+
In this example, we will create a Docker App where service images are built along with the App image.
44

5-
[Kubernetes Hands-on Workshop](https://training.play-with-kubernetes.com/kubernetes-workshop/)
5+
The [dockercoins](https://github.com/dockersamples/dockercoins) demo application is made up of five services:
6+
7+
* `rng` is a web service generating random bytes
8+
* `hasher` is a web service computing hash of POSTed data
9+
* `worker` is a background process using rng and hasher
10+
* `webui` is the web interface to watch progress
11+
* `redis` is handling storage
12+
13+
## App Definition
14+
15+
The App definition for this example is ready to use and can be found in the [coins.dockerapp](coins.dockerapp) directory in this folder.
16+
17+
Open the `coins.dockerapp/docker-compose.yml` file in a text editor:
18+
19+
```yaml
20+
version: "3.7"
21+
22+
services:
23+
rng:
24+
build: rng
25+
ports:
26+
- "${rng.port}:80"
27+
28+
hasher:
29+
build: hasher
30+
ports:
31+
- "${hasher.port}:80"
32+
33+
webui:
34+
build: webui
35+
ports:
36+
- "${webui.port}:80"
37+
38+
redis:
39+
image: redis
40+
41+
worker:
42+
build: worker
43+
```
44+
45+
You can notice that the `rng`, `webui`, `hasher` and `worker` services all have a `build` field, i.e. each service has a Dockerfile describing how the service image must be built.
46+
47+
```shell
48+
├── coins.dockerapp
49+
│   ├── docker-compose.yml
50+
│   ├── metadata.yml
51+
│   └── parameters.yml
52+
├── hasher
53+
│   ├── Dockerfile
54+
│   └── hasher.rb
55+
├── rng
56+
│   ├── Dockerfile
57+
│   └── rng.py
58+
├── webui
59+
│   ├── Dockerfile
60+
│   ├── files
61+
│   │   ├── d3.min.js
62+
│   │   ├── index.html
63+
│   │   ├── jquery-1.11.3.min.js
64+
│   │   ├── jquery.js -> jquery-1.11.3.min.js
65+
│   │   ├── rickshaw.min.css
66+
│   │   └── rickshaw.min.js
67+
│   └── webui.js
68+
└── worker
69+
├── Dockerfile
70+
└── worker.py
71+
```
72+
73+
## App Image
74+
75+
Now we are going to build an App image from this App definition. At build time, Docker App is going to build each service image then build the App image embedding the service images.
76+
77+
```shell
78+
$ docker app build -f coins.dockerapp -t myrepo/coins:0.1.0 .
79+
[+] Building 10.5s (37/37) FINISHED
80+
=> [rng internal] load build definition from Dockerfile 0.0s
81+
(...) (some build output)
82+
=> [webui internal] load build definition from Dockerfile 0.1s
83+
=> [hasher internal] load build definition from Dockerfile 0.1s
84+
=> [worker internal] load build definition from Dockerfile 0.1s
85+
(...) (rest of build output)
86+
sha256:ee61121d6bff0266404cc0077599c1ef7130289fec721
87+
```
88+
89+
If you browse the `docker app build` command output, you will see that:
90+
* the `rng`, `webui`, `hasher` and `worker` service images have been built from a Dockerfile
91+
* if you don't have it already loacally, the `redis` image will be pulled
92+
93+
## Running App
94+
95+
You can now run this App using the `docker app run` command.
96+
97+
```shell
98+
$ docker app run myrepo/coins:0.1.0
99+
Creating network dreamy_albattani_default
100+
Creating service dreamy_albattani_hasher
101+
Creating service dreamy_albattani_webui
102+
Creating service dreamy_albattani_redis
103+
Creating service dreamy_albattani_worker
104+
Creating service dreamy_albattani_rng
105+
App "dreamy_albattani" running on context "default"
6106
```
7-
rng = web service generating random bytes
8-
hasher = web service computing hash of POSTed data
9-
worker = background process using rng and hasher
10-
webui = web interface to watch progress
107+
108+
*Note: if you don't pass the `--name` flag to the `docker app run` command, a name for the running App will be automatically generated.*
109+
110+
You list the running Apps using the `docker app ls` command.
111+
112+
```shell
113+
$ docker app ls
114+
RUNNING APP APP NAME LAST ACTION RESULT CREATED MODIFIED REFERENCE
115+
dreamy_albattani coins (0.1.0) install success About a minute ago About a minute ago docker.io/myrepo/coins:0.1.0
11116
```
117+
118+
## Inspect the running App
119+
120+
Get detailed information about the running App using the `docker app inspect` command. Note that the `--pretty` option allows to get a human friendly output rather than the default JSON output.
121+
122+
```shell
123+
$ docker app inspect dreamy_albattani --pretty
124+
Running App:
125+
Name: dreamy_albattani
126+
Created: 3 minutes ago
127+
Modified: 3 minutes ago
128+
Revision: 01DT9CAEJ6TY48YMRKB4EWW357
129+
Last Action: install
130+
Result: success
131+
132+
App:
133+
Name: coins
134+
Version: 0.1.0
135+
Image Reference: docker.io/myrepo/coins:0.1.0
136+
137+
Parameters:
138+
hasher.port: "8002"
139+
rng.port: "8001"
140+
webui.port: "8000"
141+
142+
ID NAME MODE REPLICAS IMAGE PORTS
143+
adpmt82ejfrm dreamy_albattani_worker replicated 1/1 sha256:8c016797b7042227d224ce058ed099f3838904a8f8a259d0e000440851c648a1
144+
r5a8ukf2j17a dreamy_albattani_redis replicated 1/1 redis
145+
sffx1pe1b04u dreamy_albattani_hasher replicated 1/1 sha256:7ab1468f5e2b6ff8ece16b56832fa6b3547bf71375b6d71c55211e2dbe24ba11 *:8002->80/tcp
146+
uk8cixh15pob dreamy_albattani_webui replicated 1/1 sha256:75279ded158d53fc69ef7570f3e8d5e2646479bb50ddf03b9b06d24d39815ce3 *:8000->80/tcp
147+
ypx32ze6b0wt dreamy_albattani_rng replicated 1/1 sha256:9bc51dbbbdffb342468289b5bf8ad411fe2d6bdbac044cc69075c33df54919a2 *:8001->80/tcp
148+
```
149+
150+
## Remove running App and App image
151+
152+
Now, let's remove the running App.
153+
154+
```shell
155+
$ docker app rm dreamy_albattani
156+
Removing service dreamy_albattani_hasher
157+
Removing service dreamy_albattani_redis
158+
Removing service dreamy_albattani_rng
159+
Removing service dreamy_albattani_webui
160+
Removing service dreamy_albattani_worker
161+
Removing network dreamy_albattani_default
162+
```
163+
164+
And finally, let's remove the App image.
165+
166+
```shell
167+
$ docker app image rm myrepo/coins:0.1.0
168+
Deleted: myrepo/coins:0.1.0
169+
```

0 commit comments

Comments
 (0)