Making Application Collaboration Easier with Docker Application Packages

In the first blog post about the experimental Docker Application Packages, Gareth showed how our new open-source docker-app can be used to augment Compose files by adding metadata and separate settings.

Now that you know how to create an Application Package, how do you share it? Using a Docker registry solution like Docker Hub or Docker Enterprise of course! Let’s look at an example that works with the latest release of docker-app. Here’s a simple single-file format Application Package with the filename hello.dockerapp:

# This section contains your application metadata.

version: 0.1.0
name: hello
description: "A simple HTTP echo server"
maintainers:
- name: Chris Crone
  email: someone@example.com
targets:
  swarm: true
  kubernetes: true

---

# This section contains the Compose file that describes your application services.

version: '3.6'
services:
  hello:
    image: hashicorp/http-echo:${version}
    command: ["-text", "${text}"]
    ports:
      - ${port}:5678

 ---

# This section contains the default values for your application settings.

port: 5678
text: hello development
version: latest

We can save this Application Package as a Docker image using the save command:

$ docker-app save
Saved application as image: hello.dockerapp:0.1.0

As stated in the above output, the application is simply a Docker image now. We can confirm the package was saved as an image by listing the Application Packages stored as images:

$ docker image ls --filter=label=com.docker.application

REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
hello.dockerapp              0.1.0               211d7b50537b        8 minutes ago       534B

Note that the version of the image matches the version we specified in the package metadata. There is also a helper in docker-app to list all applications that you have stored as images:

$ docker-app ls

REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
hello.dockerapp              0.1.0               211d7b50537b        8 minutes ago       534B

An Application Package stored as an image can be inspected just as one would any of the other package types:

$ cd /tmp
$ docker-app inspect hello.dockerapp:0.1.0
hello 0.1.0
Maintained by: Chris Crone <someone@example.com>

A simple HTTP echo server

Setting Default
------- -------
port    5678
text    hello development
version latest

Since this Application Package is stored as an image, you can share it using Docker Hub or a private Docker registry such as Docker Enterprise Edition:

$ docker-app push --namespace ccrone
The push refers to repository [docker.io/ccrone/hello.dockerapp]
c3dd6b98b5be: Pushed 
0.1.0: digest: sha256:0a94283fda704dcd316c600fb850783803d472384fff1a4a4c4c94c062dab696 size: 524

Now that the package is on Docker Hub, it’s easy for other people to use it. For example they can render or deploy the package as they would the single-file or directory format:

$ docker-app render ccrone/hello.dockerapp
version: "3.6"
services:
  hello:
    command:
    - -text
    - hello development
    image: hashicorp/http-echo:latest
    ports:
    - mode: ingress
      target: 5678
      published: 5678
      protocol: tcp

Status?

The work on Application Packages and `docker-app` is experimental. We released it early to get your feedback. You can find the source code at https://github.com/docker/app or you can download docker-app from https://github.com/docker/app/releases.

Next Steps:

Continue reading...

Be the first to write a comment.

Leave a Reply