2021-05-24 00:11:58 +03:00
|
|
|
Undocker
|
|
|
|
--------
|
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Converts a Docker image (a bunch of layers) to a flattened "rootfs" tarball.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
|
|
|
Why?
|
2021-05-24 00:11:58 +03:00
|
|
|
----
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Docker images became a popular way to distribute applications with their
|
|
|
|
dependencies. However, Docker itself is not the best runtime environment. At
|
|
|
|
least not for everyone.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Undocker bridges the gap between application images (in docker image format)
|
2021-05-24 00:11:58 +03:00
|
|
|
and container runtimes: now you can run a Docker image with old-fashioned
|
|
|
|
tools: lxc, systemd-nspawn or systemd itself.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
|
|
|
Usage -- extract docker image
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
Download `nginx` docker image from docker hub and convert it to a rootfs:
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
```
|
2021-05-24 00:11:58 +03:00
|
|
|
skopeo copy docker://docker.io/busybox:latest docker-archive:busybox.tar
|
|
|
|
undocker rootfs busybox.tar - | tar -xv
|
2021-05-24 00:11:58 +03:00
|
|
|
```
|
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Almost the same can be done with a combination of `docker pull` and `docker
|
|
|
|
save`.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Usage -- systemd-nspawn example
|
|
|
|
-------------------------------
|
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Start with systemd-nspawn:
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
```
|
2021-05-24 00:11:58 +03:00
|
|
|
systemd-nspawn -D $PWD busybox httpd -vfp 8080
|
2021-05-24 00:11:58 +03:00
|
|
|
```
|
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Usage -- plain old systemd
|
|
|
|
--------------------------
|
2021-05-24 00:11:58 +03:00
|
|
|
|
|
|
|
```
|
2021-05-24 00:11:58 +03:00
|
|
|
systemd-run \
|
|
|
|
--wait --pty --collect --service-type=exec \
|
|
|
|
-p PrivateUsers=true \
|
|
|
|
-p DynamicUser=yes \
|
|
|
|
-p ProtectProc=invisible \
|
|
|
|
-p RootDirectory=$PWD \
|
|
|
|
-- busybox httpd -vfp 8080
|
2021-05-24 00:11:58 +03:00
|
|
|
```
|
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Good things like `PrivateUsers`, `DynamicUser`, `ProtectProc` and other
|
|
|
|
[systemd protections][1] are available, just like to any systemd unit.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Notes & gotchas
|
|
|
|
---------------
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
`unocker` does not magically enable you to run containers from the internet. In
|
|
|
|
fact, many will need significant tuning or not work at all. Thus you will still
|
|
|
|
need to understand what are you running.
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
Contributions
|
|
|
|
-------------
|
2021-05-24 00:11:58 +03:00
|
|
|
|
2021-05-24 00:11:58 +03:00
|
|
|
I will accept pull request for code (including tests) and documentation. I am
|
2021-05-24 00:11:58 +03:00
|
|
|
unlikely to react to issue reports without a patch.
|
|
|
|
|
|
|
|
[1]: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|