Add an example of building an application and running in Docker or LinuxKit

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-06-07 16:04:09 +01:00
parent dbe50976c3
commit 9a3ac36236
4 changed files with 62 additions and 0 deletions

23
examples/README.md Normal file
View File

@ -0,0 +1,23 @@
Examples of building an image to run on LinuxKit or on a host
Currently the `moby` tool can output formats suitable for LinuxKit to boot on
a VM, and also some formats for running natively.
The `docker` format adds a `Dockerfile` to the tarball and expects a similar
file structure to `LinuxKit` but with the low level system setup pieces removed
as this will already be set up in a container.
The `mobytest/init-container` image in this repository has an example setup that
initialises `containerd` in exactly the same way as it runs in LinuxKit, which will
then start the `onboot` and `service` containers. The example below shows how you
can run `nginx` on either of these base configs.
```
moby build -output docker -o - docker.yml nginx.yml | docker build -t dockertest -
docker run -d -p 80:80 --privileged dockertest
moby build -output kernel+initrd linuxkit.yml nginx.yml
linuxkit run nginx
```
Both of these will run the same `nginx` either in a VM or a container.

9
examples/docker.yml Normal file
View File

@ -0,0 +1,9 @@
init:
- mobytest/init-container:b5de246b2790d74d53bae583a95c87869ca003e6
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
- linuxkit/containerd:5749f2e9e65395cc6635229e8da0e0d484320ddf
- linuxkit/ca-certificates:75cf419fb58770884c3464eb687ec8dfc704169d
trust:
org:
- linuxkit
- mobytest

18
examples/linuxkit.yml Normal file
View File

@ -0,0 +1,18 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0"
init:
- linuxkit/init:1b8a7e394d2ec2f1fdb4d67645829d1b5bdca037
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
- linuxkit/containerd:5749f2e9e65395cc6635229e8da0e0d484320ddf
- linuxkit/ca-certificates:75cf419fb58770884c3464eb687ec8dfc704169d
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:7d2b8aaaf20c24ad7d11a5ea2ea5b4a80dc966f1"
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
services:
- name: rngd
image: "linuxkit/rngd:1fa4de44c961bb5075647181891a3e7e7ba51c31"
trust:
org:
- linuxkit

12
examples/nginx.yml Normal file
View File

@ -0,0 +1,12 @@
services:
- name: nginx
image: "nginx:alpine"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
trust:
org:
- library