• This repository has been archived on 13/Jun/2021
  • Stars
    star
    1,575
  • Rank 29,719 (Top 0.6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make your Docker Compose applications reusable, and share them on Docker Hub

⚠️ Deprecation Notice: This project and repository is now deprecated and is no longer in active development, see the related roadmap issue. If you'd like to continue using CNAB for packaging your applications, check out Porter.

Docker App

Docker App is a Cloud Native application packaging framework with which developers and devops can build, share, and run a set of microservices as a single entity. Docker Apps are based on the Compose format, which permits docker-compose users to easily share their Compose-based multiservice applications via container registries. By leveraging containers, Docker App makes it possible to easily change parts of the application and to share the application through container registries.

Table of Contents

What are the benefits offered by Docker App?

  • Simple management of Docker Apps across different teams and between different environments (Development/QA/Staging/Production)
  • Easy sharing of multi-service applications to container registries (e.g., Docker Hub or Docker Trusted Registry)
  • Having a clear separation of parameters to be modified at runtime
  • Support for multiple orchestrators (Swarm or Kubernetes)
  • Provides the very same UX flow as the one for Docker images
  • Implements the CNAB industry standard
  • Offers full support for Docker Contexts

How does Docker App work?

The Docker App workflow is quite similar to the Docker image workflow. From an App definition, you can build an App image, share it on Docker Hub, and run your App on an orchestrator.

Image showing Docker CLI command flow

Using Docker App

Four primary steps comprise the Docker App process:

  1. Writing an App Definition
  2. Building an App Image
  3. Sharing the App on the Hub (optional)
  4. Running the App

Writing an App definition

The first step in using Docker App is to write the App definition. This definition can be created (1) from an existing Compose file using the docker app init command (2) via a template from the Application Designer, or (3) from scratch.

The App definition is a .dockerapp folder that contains three distinct pieces: metadata, a service list, and the parameters.

File Description
metadata.yml metadata including the App name and version
docker-compose.yml Service list defined in a Compose file
parameters.yml Parameters that can be changed when running the App

*Note: To store additional files in Docker Apps, such as prod.yml, test.yml or other config files, you need only to add these files to the .dockerapp directory. All files will be packaged into the App image through the use of the docker app build command.

Building an App image

Once the App definition is written, the next step is to build the App image from the App definition using the docker app build command. With this command you can tag your App image, set build-time variables, or make the build quiet.

Note that service images inside of an App image are immutable, meaning that the App version ties to a fixed list of service images (i.e., updating the images inside of a Docker App requires rebuilding the App image). This makes deploying applications more deterministic.

Sharing the App on the Hub

You can push any App image already built or pulled to Docker Hub (or any OCI compliant registry) using the docker app push command. You can also pull App images from any OCI compliant registry using the docker app pull command.

When pushing an App image, all the service images used by the application are pushed at the same time inside a single entity. The version of each service image is resolved at build time from its tag.

Running the App

The final Docker App step is to actually run your App using the docker app run command. You can either pick up an App image from Docker Hub or one that you built locally and deploy it to Swarm or Kubernetes.

Example

Using the hello-world application example, we are going to build, share, and run a Docker App that launches an HTTP server that prints the text variable value when hit on the configured port.

Note: Before starting, confirm that the Docker App CLI plugin is installed on your machine

App definition

First, create an App definition from an existing Compose file.

Create a docker-compose.yml file that has the following content:

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

Next, create an App definition using the docker app init command:

$ docker app init --compose-file docker-compose.yml hello
Created "hello.dockerapp"
$ tree
.
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ hello.dockerapp
 Β Β  β”œβ”€β”€ docker-compose.yml
Β  Β  β”œβ”€β”€ metadata.yml
Β Β   └── parameters.yml

A new folder named hello.dockerapp now exists, which contains three YAML documents:

  • metadata
  • a Compose file
  • parameters for your application to be used at runtime

The metadata.yml file should display as follows:

version: 0.1.0
name: hello
description: A simple text server
maintainers:
- name: yourusername
  email:

The Compose file is the one that was passed in parameters. Thus, if you open parameters.yml you will notice that it is empty, as the Compose file isn’t using any variable.

Using parameters

Edit the docker-compose.yml file in the hello.dockerapp directory to add some variables:

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

Next, define the default values for the App in the parameters.yml file:

port: 5678
text: hello development

Building an App image

Next, build an App image:

$ docker app build . -f hello.dockerapp -t myrepo/hello:0.1.0
[+] Building 0.7s (6/6) FINISHED
(...) (Build output)
sha256:4a492748ae55170daadd1ddfff4db30e0ef3d38bf0f57a913512caa323e140de

At this point, an App image with the myrepo/hello:1.0.1 tag has been built from the hello.dockerapp App definition. This immutable App image includes all the service images at fixed versions that you can run or share.

Sharing and running the App

To share your App image, push it to a container registry.

$ docker app push myrepo/hello:0.1.0

Now run your App:

$ docker app run myrepo/hello:0.1.0 

You can specify the Docker endpoint where an application is installed using a context. By default, your App will run on the currently active context. You can select another context with the docker context use command, and the docker app run command will thereafter run your app on this particular context.

Whenever you define such a context, the installer image will run in the default context (i.e., on local host). You can then use the --installer-context to target another context to run the installer image.

$ docker context create remote --description "remote cluster" --docker host=tcp://<remote-ip>:<remote-port>
Successfully created context "remote"

$ docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT                ORCHESTRATOR
default *           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   https://localhost:6443 (default)   swarm
remote              remote cluster                            tcp://<remote-ip>:<remote-port>

$ docker context use remote
$ docker app run myrepo/hello:0.1.0

CNAB

Docker Apps are Docker’s implementation of the industry standard Cloud Native Application Bundle (CNAB). CNAB 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.

Installation

Docker App is a command line plugin (not be confused with docker engine plugins) that extends the docker command with app sub-commands. It requires Docker CLI 19.03.0 or later, with experimental features enabled. Either set environment variable DOCKER_CLI_EXPERIMENTAL=enabled or update your docker CLI configuration.

Note: The docker plugin install command cannot be used to install Docker-app.

Linux or macOS

Download your OS tarball:

export OSTYPE="$(uname | tr A-Z a-z)"
curl -fsSL --output "/tmp/docker-app-${OSTYPE}.tar.gz" "https://github.com/docker/app/releases/download/v0.8.0/docker-app-${OSTYPE}.tar.gz"
tar xf "/tmp/docker-app-${OSTYPE}.tar.gz" -C /tmp/

Install as a Docker CLI plugin:

mkdir -p ~/.docker/cli-plugins && cp "/tmp/docker-app-plugin-${OSTYPE}" ~/.docker/cli-plugins/docker-app

Windows

Download the Windows tarball:

Invoke-WebRequest -Uri https://github.com/docker/app/releases/download/v0.8.0/docker-app-windows.tar.gz -OutFile docker-app.tar.gz -UseBasicParsing
tar xf "docker-app.tar.gz"

Install as a Docker CLI plugin:

New-Item -ItemType Directory -Path ~/.docker/cli-plugins -ErrorAction SilentlyContinue
cp docker-app-plugin-windows.exe ~/.docker/cli-plugins/docker-app.exe

Next steps

If you're interested in contributing to the project, jump to BUILDING.md and CONTRIBUTING.md.

Further examples are available in the examples directory.

More Repositories

1

awesome-compose

Awesome Docker Compose samples
HTML
34,762
star
2

compose

Define and run multi-container applications with Docker
Go
33,472
star
3

kitematic

Visual Docker Container Management on Mac & Windows
JavaScript
12,247
star
4

labs

This is a collection of tutorials for learning how to use Docker with various tools. Contributions welcome.
PHP
11,518
star
5

docker-bench-security

The Docker Bench for Security is a script that checks for dozens of common best-practices around deploying Docker containers in production.
Shell
9,038
star
6

dockercraft

Docker + Minecraft = Dockercraft
Lua
7,185
star
7

docker-py

A Python library for the Docker Engine API
Python
6,800
star
8

machine

Machine management for a container-centric world
Go
6,628
star
9

cli

The Docker CLI
Go
4,850
star
10

build-push-action

GitHub Action to build and push Docker images with Buildx
TypeScript
4,242
star
11

docs

Source repo for Docker's Documentation
Markdown
4,163
star
12

genai-stack

Langchain + Docker + Neo4j + Ollama
Python
3,907
star
13

buildx

Docker CLI plugin for extended build capabilities with BuildKit
Go
3,513
star
14

getting-started

Getting started with Docker
JavaScript
2,911
star
15

libchan

Like Go channels over the network
Go
2,470
star
16

for-mac

Bug reports for Docker Desktop for Mac
2,426
star
17

docker-install

Docker installation script
Shell
2,281
star
18

for-win

Bug reports for Docker Desktop for Windows
1,849
star
19

roadmap

Welcome to the Public Roadmap for All Things Docker! We welcome your ideas.
1,734
star
20

compose-on-kubernetes

Deploy applications described in Compose onto Kubernetes clusters
Go
1,419
star
21

docker-credential-helpers

Programs to keep Docker login credentials safe by storing in platform keystores
Go
1,060
star
22

login-action

GitHub Action to login against a Docker registry
TypeScript
1,029
star
23

setup-buildx-action

GitHub Action to set up Docker Buildx
TypeScript
933
star
24

metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
TypeScript
888
star
25

libkv

Distributed key/value store abstraction library
Go
854
star
26

for-linux

Docker Engine for Linux
751
star
27

libcompose

*Unmaintained/Deprecated* An experimental go library providing Compose-like functionality
Go
585
star
28

setup-qemu-action

GitHub Action to install QEMU static binaries
TypeScript
431
star
29

welcome-to-docker

JavaScript
422
star
30

go-plugins-helpers

Go helper packages to extend the Docker Engine
Go
331
star
31

hub-tool

πŸ§ͺ Docker Hub experimental CLI tool
Go
330
star
32

community

326
star
33

scout-cli

Docker Scout CLI
Shell
290
star
34

engine-api

DEPRECATED: Please see https://github.com/docker/docker/tree/master/client
Go
265
star
35

hub-feedback

Feedback and bug reports for the Docker Hub
233
star
36

doodle

A Home for Docker Doodles
Go
221
star
37

go-units

Parse and print size and time units in human-readable format
Go
215
star
38

go-connections

Utility package to work with network connections
Go
212
star
39

compose-switch

Go
199
star
40

go-docker

(Still WIP) Official Go SDK for Docker
Go
189
star
41

scan-cli-plugin

Docker Scan is a Command Line Interface to run vulnerability detection on your Dockerfiles and Docker images
Go
181
star
42

bake-action

GitHub Action to use Docker Buildx Bake as a high-level build command
TypeScript
176
star
43

gordon

Cli application to manage github pull requests
Go
176
star
44

docker-ce-packaging

Packaging scripts for Docker CE
Makefile
174
star
45

github-actions

⚠️ This repository is deprecated and has been replaced by docker/build-push-action@v2
Go
163
star
46

sbom-cli-plugin

Plugin for Docker CLI to support SBOM creation using Syft
Go
153
star
47

extensions-sdk

Desktop Extensions SDK
142
star
48

hacktoberfest-2022

Docker Hacktoberfest 2022
140
star
49

go-events

Composable event distribution for Go
Go
131
star
50

node-sdk

Docker CLI gRPC JavaScript SDK
JavaScript
110
star
51

libtrust

Primitives for identity and authorization
Go
107
star
52

compose-ecs

Deploy compose application on ECS
Go
100
star
53

golang-cross

Dockerfile
97
star
54

getting-started-app

A simple application for the getting started guide in Docker's documentation
JavaScript
93
star
55

multi-container-app

EJS
88
star
56

volumes-backup-extension

Back up, clone, restore, and share Docker volumes effortlessly.
PLpgSQL
87
star
57

go-metrics

Package for metrics collection in Docker projects
Go
87
star
58

scout-action

Docker Scout GitHub Action
JavaScript
78
star
59

desktop-linux

Bug reports for Docker Desktop for Linux
76
star
60

containerd-packaging

Linux distro packaging for containerd
Shell
68
star
61

opensource

Contains documentation and scripts related to the management of Open Source at Docker
Go
63
star
62

dev-environments

63
star
63

actions-toolkit

Toolkit for Docker (GitHub) Actions
TypeScript
58
star
64

extension-ideas

A place to suggest new ideas for Docker Extensions and get new ideas of what to build for the larger Docker community
48
star
65

binfmt

Please use https://github.com/linuxkit/linuxkit/tree/master/pkg/binfmt instead of this repo
Go
44
star
66

dev-envs-extension

TypeScript
40
star
67

code-of-conduct

40
star
68

index-cli-plugin

Go
40
star
69

whalesay

A repository in support of the Docker's official whalesay image
Perl
39
star
70

labs-make-runbook

TypeScript
38
star
71

HttpOverStream

.NET library for using HTTP 1.1 over streams, especially Windows Named Pipes
C#
33
star
72

scout-demo-service

Dockerfile
33
star
73

buildkit-syft-scanner

BuildKit Syft scanner
Go
23
star
74

get-involved

Get Involved with Docker
CSS
23
star
75

getting-started-todo-app

Sample application to get started with Docker
JavaScript
23
star
76

babashka-pod-docker

Go
20
star
77

packaging

Docker Packaging (apk, deb, rpm, static)
Dockerfile
20
star
78

buildx-desktop

19
star
79

cli-docs-tool

Utilities to generate (reference) documentation for the docker CLI
Go
19
star
80

docker-nodejs-sample

A simple Node.js application for the guide in Docker's documentation
JavaScript
18
star
81

go

Go packages with small patches autogenerated (used for canonical/json)
Go
18
star
82

base-cli-plugin

Experimental Docker CLI plugin to detect base images
Go
16
star
83

notary-official-images

Shell
16
star
84

python-docker

A simple Python app for the Python Language Guide in Docker's Docs
Python
16
star
85

go-imageinspect

Go
15
star
86

docker-dotnet-sample

A simple .NET web application
HTML
14
star
87

github-actions-runner

Docker's containerized github-actions runner
Shell
13
star
88

labs-ai-tools-for-devs

Project AI For Devs (chat-sdlc) - AI agents running containerized tools
Clojure
13
star
89

dc23-secure-workshop

DockerCon 2023 Secure Development with Docker hands-on exercises code
Dockerfile
11
star
90

extensions-submissions

Submit your Docker Extension here
Shell
11
star
91

docker-php-sample

A simple PHP application
PHP
10
star
92

docker-vscode

The Docker VSCode EAP is an extension for VSCode which provides an early preview into new features by Docker.
10
star
93

python-docker-dev

A simple Python app for the Python Language Guide in Docker's Docs
Python
10
star
94

import-restrictions

Restrict imports in your go project
Go
9
star
95

desktop-action

Docker Desktop action
9
star
96

labs-tape

Tape is for packaging applications
Go
8
star
97

engine-sync

Sync moby/moby with docker/engine
Shell
8
star
98

database-extension

TypeScript
7
star
99

bindmount-apps

EJS
7
star
100

compose-desktop

5
star