linuxkit/projects/compose
Avi Deitcher 14c29db5c2
Containerd v2.0.3 (#4112)
* containerd to semver v2.0.3

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* containerd v2.0.3 plus commits to fix blkdiscard

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* update containerd-dev dependencies

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* updated pkg/init and pkg/containerd deps

Signed-off-by: Avi Deitcher <avi@deitcher.net>

---------

Signed-off-by: Avi Deitcher <avi@deitcher.net>
2025-03-06 17:12:07 +02:00
..
image Updated Compose and Docker versions. 2019-03-17 18:18:37 +00:00
.gitignore add compose dynamic 2017-06-04 16:18:34 +03:00
compose-dynamic.yml Containerd v2.0.3 (#4112) 2025-03-06 17:12:07 +02:00
compose-static.yml Containerd v2.0.3 (#4112) 2025-03-06 17:12:07 +02:00
docker-compose.yml add compose dynamic 2017-06-04 16:18:34 +03:00
html-a.html add compose dynamic 2017-06-04 16:18:34 +03:00
html-b.html add compose dynamic 2017-06-04 16:18:34 +03:00
Makefile Remove Notary and Content Trust 2021-03-30 14:51:11 +01:00
README.md add compose dynamic 2017-06-04 16:18:34 +03:00

Compose Project

The purpose of this project is to show how moby and linuxkit can be used to build a runnable linuxkit image with compose-style apps ready-to-run.

The apps are simple:

  • nginx serving app A
  • nginx serving app B
  • traefik routing on the basis of hostname between apps A and B

Compose Methods

We provide samples of two methods for using compose: dynamic and static.

Both methods use the image linuxkit/compose. The image does the following:

  1. Wait for compose to be ready.
  2. If there are any tar files available in /images/*.tar, treat them as tarred up docker images and load them into docker via docker load ...
  3. Run docker compose ...

The only difference between dynamic and static is whether or not container images are pre-loaded in the linuxkit image.

  • Compose: the linuxkit/compose image looks for a compose file at /compose/docker-compose.yml
  • Images: the linuxkit/compose image looks for tarred container images at /compose/images/*.tar

Dynamic

Dynamic loads the compose config into the linuxkit image at build time. Container images are not pre-loaded, and thus docker loads the container images from the registry at run-time. This is no different than doing the following:

  1. Using the docker linuxkit image
  2. Connecting remotely via the docker API
  3. Running the compose file remotely

Except that the compose is run at launch time, and there is no need for a remote connection to the docker API.

It works by loading the docker-compose.yml file onto the linuxkit image, and making it available to the compose container image via a bind-mount.

To build a dynamic image, do make dynamic. To run it, do make run-dynamic.

Static

Static loads the compose config and the container images into the linuxkit image at build time. When run, docker loads the images from its local cache and does not depend on access to a registry.

It works by loading the docker-compose.yml file onto the linuxkit image and tarred up container image files. It then makes them available to the compose container image via bind-mounts.

To build a static image, do make static. To run it, do make run-static.

Static images pre-load them by doing:

  1. Download the image locally docker image pull <image>
  2. Save the image to a local tar file docker image save -o <image> <imagename>.tar
  3. copy the tar file to the container image
  4. When starting the container from the image with the files, load the images into docker before running compose: docker image load -i <image> && rm -f <imagename>.tar

Conversion

A final option would be converting all of the containers defined in a docker-compose.yml into linuxkit services. It also would require setting up appropriate networks and other services provided by docker when running compose.

An example may be added in the future.