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

Commit d17548a

Browse files
Update README with CNAB
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent 5633f15 commit d17548a

4 files changed

Lines changed: 54 additions & 21 deletions

File tree

README.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,47 @@ You can then run using that configuration file like so:
145145
$ docker-app render -f prod.yml
146146
```
147147

148-
149148
More examples are available in the [examples](examples) directory.
150149

150+
## CNAB
151+
152+
Under the hood `docker-app` produces a CNAB bundle (a docker invocation image and a `bundle.json`) from an Application Package, but is also a generic CNAB client.
153+
CNAB proposes four actions, and docker-app adds them as commands:
154+
- `install`
155+
- `upgrade`
156+
- `status`
157+
- `uninstall`
158+
159+
**Note**: These four commands needs a Docker Context to know which daemon or orchestrator to target.
160+
161+
```sh
162+
$ docker context create swarm --description "swarm context" --default-stack-orchestrator=swarm --docker=host=unix:///var/run/docker.sock
163+
swarm
164+
Successfully created context "swarm"
165+
166+
$ docker context ls
167+
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
168+
default Current DOCKER_HOST based configuration
169+
swarm * swarm context unix:///var/run/docker.sock swarm
170+
```
171+
172+
Here is an example installing an application package, querying a status and then uninstalling it:
173+
```sh
174+
$ docker-app install examples/hello-world/hello-world.dockerapp --name hello --target-context=swarm
175+
Creating network hello_default
176+
Creating service hello_hello
177+
178+
$ export DOCKER_TARGET_CONTEXT=swarm
179+
180+
$ docker-app status hello
181+
ID NAME MODE REPLICAS IMAGE PORTS
182+
0m1wn7jrgkgj hello_hello replicated 1/1 hashicorp/http-echo:latest *:8080->5678/tcp
183+
184+
$ docker-app uninstall hello
185+
Removing service hello_hello
186+
Removing network hello_default
187+
```
188+
151189
## Installation
152190

153191
Pre-built binaries are available on [GitHub releases](https://github.com/docker/app/releases) for Windows, Linux and macOS.
@@ -158,7 +196,7 @@ tar xf docker-app-linux.tar.gz
158196
cp docker-app-linux /usr/local/bin/docker-app
159197
```
160198

161-
**Note:** To use Application Packages as images (i.e.: `save`, `push`, or `deploy` when package is not present locally) on Windows, one must be in Linux container mode.
199+
**Note:** To use Application Packages as images (i.e.: `save`, `push`, or `install` when package is not present locally) on Windows, one must be in Linux container mode.
162200

163201
## Single file or directory representation
164202

@@ -172,7 +210,7 @@ Note that you cannot store attachments in the single file format. If you want to
172210

173211
## Attachments (Storing additional files)
174212

175-
If you want to store additional files in the application package, such as `prod.yml`, `test.yml` or other config files, use the directory format and simply place these files inside the *.dockerapp/ directory. These will be bundled into the package when using `docker-app push`
213+
If you want to store additional files in the application package, such as `prod.yml`, `test.yml` or other config files, use the directory format and simply place these files inside the *.dockerapp/ directory. These will be bundled into the package when using `docker-app push`.
176214

177215
## Sharing your application on the Hub
178216

@@ -215,26 +253,30 @@ Usage: docker-app [OPTIONS] COMMAND
215253
Build and deploy Docker Application Packages.
216254
217255
Options:
218-
-c, --context string context to use to connect to the daemon (overrides host flag, DOCKER_HOST env var and default context set with "docker context use")
256+
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
219257
-D, --debug Enable debug mode
220258
-H, --host list Daemon socket(s) to connect to
221259
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
222260
--tls Use TLS; implied by --tlsverify
223-
--tlscacert string Trust certs signed only by this CA (default "/Users/chris/.docker/ca.pem")
224-
--tlscert string Path to TLS certificate file (default "/Users/chris/.docker/cert.pem")
225-
--tlskey string Path to TLS key file (default "/Users/chris/.docker/key.pem")
261+
--tlscacert string Trust certs signed only by this CA (default "/Users/silvin/.docker/ca.pem")
262+
--tlscert string Path to TLS certificate file (default "/Users/silvin/.docker/cert.pem")
263+
--tlskey string Path to TLS key file (default "/Users/silvin/.docker/key.pem")
226264
--tlsverify Use TLS and verify the remote
227265
-v, --version Print version information
228266
229267
Commands:
268+
bundle Create a CNAB invocation image and bundle.json for the application.
230269
completion Generates completion scripts for the specified shell (bash or zsh)
231-
deploy Deploy or update an application
232270
init Start building a Docker application
233271
inspect Shows metadata, parameters and a summary of the compose file for a given application
272+
install Install an application
234273
merge Merge a multi-file application into a single file
235274
push Push the application to a registry
236275
render Render the Compose file for the application
237276
split Split a single-file application into multiple files
277+
status Get an application status
278+
uninstall Uninstall an application
279+
upgrade Upgrade an installed application
238280
validate Checks the rendered application is syntactically correct
239281
version Print version information
240282

cmd/docker-app/install.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func runInstall(dockerCli command.Cli, appname string, opts installOptions) erro
103103
return err
104104
}
105105

106-
bndl, err := resolveBundle(dockerCli, opts.namespace, appname, opts.insecure)
106+
bndl, err := resolveBundle(dockerCli, opts.namespace, appname)
107107
if err != nil {
108108
return err
109109
}
@@ -232,7 +232,7 @@ func extractAndLoadAppBasedBundle(dockerCli command.Cli, namespace, name string)
232232
return makeBundleFromApp(dockerCli, app, namespace, "")
233233
}
234234

235-
func resolveBundle(dockerCli command.Cli, namespace, name string, insecure bool) (*bundle.Bundle, error) {
235+
func resolveBundle(dockerCli command.Cli, namespace, name string) (*bundle.Bundle, error) {
236236
// resolution logic:
237237
// - if there is a docker-app package in working directory, or an http:// / https:// prefix, use packager.Extract result
238238
// - the name has a .json or .cnab extension and refers to an existing file or web resource: load the bundle
@@ -267,14 +267,6 @@ func getTargetContext(optstargetContext string) string {
267267
return targetContext
268268
}
269269

270-
func stringsKVToStringInterface(src map[string]string) map[string]interface{} {
271-
result := map[string]interface{}{}
272-
for k, v := range src {
273-
result[k] = v
274-
}
275-
return result
276-
}
277-
278270
func prepareCredentialSet(contextName string, contextStore store.Store, b *bundle.Bundle, namedCredentialsets []string) (map[string]string, error) {
279271
creds := map[string]string{}
280272
for _, file := range namedCredentialsets {
@@ -306,7 +298,7 @@ func prepareCredentialSet(contextName string, contextStore store.Store, b *bundl
306298
_, requiresDockerContext := b.Credentials["docker.context"]
307299
_, hasDockerContext := creds["docker.context"]
308300
if requiresDockerContext && !hasDockerContext {
309-
return nil, errors.New("no target context specified. use use --target-context= or DOCKER_TARGET_CONTEXT= to define it")
301+
return nil, errors.New("no target context specified. Use --target-context= or DOCKER_TARGET_CONTEXT= to define it")
310302
}
311303
return creds, nil
312304
}

cmd/docker-app/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func runUpgrade(dockerCli command.Cli, installationName string, opts upgradeOpti
5656
}
5757

5858
if opts.bundleOrDockerApp != "" {
59-
b, err := resolveBundle(dockerCli, opts.namespace, opts.bundleOrDockerApp, opts.insecure)
59+
b, err := resolveBundle(dockerCli, opts.namespace, opts.bundleOrDockerApp)
6060
if err != nil {
6161
return err
6262
}

cmd/run/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const (
1313
cnabActionUninstall = cnabAction("uninstall")
1414
cnabActionUpgrade = cnabAction("upgrade")
1515
cnabActionStatus = cnabAction("status")
16-
cnabActionInspect = cnabAction("inspect")
1716
)
1817

1918
type cnabOperation struct {

0 commit comments

Comments
 (0)