Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eab7c3c1ef | |||
| ec61d24fd4 | |||
| d3933efd74 | |||
| a265915b21 | |||
| 8c00e74df9 | |||
| 5e297827d3 | |||
| dc03b29e6e | |||
| f02af98ac5 | |||
| cca579d218 | |||
| 436a866f5d | |||
| 71aab65b75 |
@@ -14,7 +14,7 @@ tasks:
|
|||||||
- lint: |
|
- lint: |
|
||||||
make -C undocker -O -j$(nproc) lint
|
make -C undocker -O -j$(nproc) lint
|
||||||
- binaries: |
|
- binaries: |
|
||||||
make -C undocker -O -j$(nproc) sha256sum.txt
|
make -C undocker -O -j$(nproc) all
|
||||||
cat undocker/sha256sum.txt
|
cat undocker/sha256sum-*.txt
|
||||||
artifacts:
|
artifacts:
|
||||||
- undocker/coverage.html
|
- undocker/coverage.html
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
/undocker
|
||||||
/undocker-*
|
/undocker-*
|
||||||
coverage.html
|
coverage.html
|
||||||
sha256sum.txt*
|
sha256sum.txt*
|
||||||
|
|||||||
14
Makefile
14
Makefile
@@ -1,6 +1,5 @@
|
|||||||
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
|
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
|
||||||
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
|
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
|
||||||
GOBIN = $(shell go env GOPATH)/bin/
|
|
||||||
GOOSARCHS = $(sort darwin/amd64 linux/amd64)
|
GOOSARCHS = $(sort darwin/amd64 linux/amd64)
|
||||||
|
|
||||||
VSN ?= $(shell git describe --dirty)
|
VSN ?= $(shell git describe --dirty)
|
||||||
@@ -24,12 +23,15 @@ $(foreach goosarch,$(GOOSARCHS),\
|
|||||||
$(eval $(call undockertarget,$(word 1,$(subst /, ,$(goosarch))),$(word 2,$(subst /, ,$(goosarch))))))
|
$(eval $(call undockertarget,$(word 1,$(subst /, ,$(goosarch))),$(word 2,$(subst /, ,$(goosarch))))))
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(UNDOCKERS)
|
all: $(UNDOCKERS) sha256sum-$(VSN).txt
|
||||||
|
|
||||||
|
.PHONY: sha256sum-asc
|
||||||
|
sha256sum-asc: sha256sum-$(VSN).txt.asc
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
go vet ./...
|
go vet ./...
|
||||||
$(GOBIN)staticcheck -f stylish ./...
|
$(shell go env GOPATH)/bin/staticcheck -f stylish ./...
|
||||||
shellcheck $(SCRIPTS)
|
shellcheck $(SCRIPTS)
|
||||||
|
|
||||||
.INTERMEDIATE: coverage.out
|
.INTERMEDIATE: coverage.out
|
||||||
@@ -39,12 +41,12 @@ coverage.out: $(GODEPS)
|
|||||||
coverage.html: coverage.out
|
coverage.html: coverage.out
|
||||||
go tool cover -html=$< -o $@
|
go tool cover -html=$< -o $@
|
||||||
|
|
||||||
sha256sum.txt: $(UNDOCKERS)
|
sha256sum-$(VSN).txt: $(UNDOCKERS)
|
||||||
sha256sum $(UNDOCKERS) > $@
|
sha256sum $(UNDOCKERS) > $@
|
||||||
|
|
||||||
sha256sum.txt.asc: sha256sum.txt
|
sha256sum-$(VSN).txt.asc: sha256sum-$(VSN).txt
|
||||||
gpg --clearsign $<
|
gpg --clearsign $<
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f undocker-*-v* coverage.html sha256sum.txt sha256sum.txt.asc
|
rm -f undocker-*-v* coverage.html sha256sum*.txt sha256sum*.txt.asc
|
||||||
|
|||||||
68
README.md
68
README.md
@@ -23,16 +23,12 @@ Undocker has no dependencies outside Golang stdlib.
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
We recommend using [officially released binaries][3]. To build the project
|
You may use [officially released binaries][3], or build it:
|
||||||
instead, run:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ make undocker
|
$ make undocker
|
||||||
```
|
```
|
||||||
|
|
||||||
The number of officially released binaries is quite limited. If you'd like me
|
|
||||||
to expand a list, please contribute a patch to the Makefile.
|
|
||||||
|
|
||||||
Usage: convert docker image to rootfs
|
Usage: convert docker image to rootfs
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
@@ -40,50 +36,41 @@ Download `busybox` docker image from docker hub and convert it to a rootfs:
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ skopeo copy docker://docker.io/busybox:latest docker-archive:busybox.tar
|
$ skopeo copy docker://docker.io/busybox:latest docker-archive:busybox.tar
|
||||||
$ undocker busybox.tar - | tar -tv | head -10
|
$ undocker busybox.tar - | tar -xv | sponge | head -10; echo '<...>'
|
||||||
drwxr-xr-x 0/0 0 2021-05-17 22:07 bin/
|
bin/
|
||||||
-rwxr-xr-x 0/0 1149184 2021-05-17 22:07 bin/[
|
bin/[
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/[[ link to bin/[
|
bin/[[
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/acpid link to bin/[
|
bin/acpid
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/add-shell link to bin/[
|
bin/add-shell
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/addgroup link to bin/[
|
bin/addgroup
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/adduser link to bin/[
|
bin/adduser
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/adjtimex link to bin/[
|
bin/adjtimex
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/ar link to bin/[
|
bin/ar
|
||||||
hrwxr-xr-x 0/0 0 2021-05-17 22:07 bin/arch link to bin/[
|
bin/arch
|
||||||
|
<...>
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also refer [here][2] for other ways to download Docker images. There
|
Refer [here][2] for other ways to download Docker images. There are many.
|
||||||
are many.
|
|
||||||
|
|
||||||
Converting a [1.1GB Docker image with 77
|
On author's laptop converting a [1.1GB Docker image with 77
|
||||||
layers](https://hub.docker.com/r/homeassistant/home-assistant) takes around 4
|
layers](https://hub.docker.com/r/homeassistant/home-assistant) takes around 3
|
||||||
seconds and on a reasonably powerful Intel laptop.
|
seconds and uses ~65MB of residential memory.
|
||||||
|
|
||||||
Usage example: systemd-nspawn
|
Usage example: systemd
|
||||||
-----------------------------
|
----------------------
|
||||||
|
|
||||||
Start with systemd-nspawn:
|
|
||||||
|
|
||||||
```
|
|
||||||
systemd-nspawn -D $PWD busybox httpd -vfp 8080
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage example: plain old systemd
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
```
|
```
|
||||||
systemd-run \
|
systemd-run \
|
||||||
--wait --pty --collect --service-type=exec \
|
--wait --pty --collect --service-type=exec \
|
||||||
|
-p RootDirectory=$PWD \
|
||||||
|
-p ProtectProc=invisible \
|
||||||
-p PrivateUsers=true \
|
-p PrivateUsers=true \
|
||||||
-p DynamicUser=yes \
|
-p DynamicUser=yes \
|
||||||
-p ProtectProc=invisible \
|
|
||||||
-p RootDirectory=$PWD \
|
|
||||||
-- busybox httpd -vfp 8080
|
-- busybox httpd -vfp 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
Good things like `PrivateUsers`, `DynamicUser`, `ProtectProc` and other
|
[Systemd protections][1] like `PrivateUsers`, `DynamicUser`, `ProtectProc` and
|
||||||
[systemd protections][1] are available, just like to any systemd unit.
|
others are available, just like to any systemd unit.
|
||||||
|
|
||||||
Similar Projects
|
Similar Projects
|
||||||
----------------
|
----------------
|
||||||
@@ -102,7 +89,7 @@ Contributions
|
|||||||
|
|
||||||
The following contributions may be accepted:
|
The following contributions may be accepted:
|
||||||
|
|
||||||
- Pull requests (patchsets) with accompanying tests.
|
- Patchsets, with accompanying tests.
|
||||||
- Regression reports.
|
- Regression reports.
|
||||||
|
|
||||||
If you found a container that undocker cannot extract, or extracts incorrectly
|
If you found a container that undocker cannot extract, or extracts incorrectly
|
||||||
@@ -113,6 +100,12 @@ Reports of regression reports must provide examples of "works before" and "does
|
|||||||
not work after". Issues without an accompanying patch will most likely be
|
not work after". Issues without an accompanying patch will most likely be
|
||||||
rejected.
|
rejected.
|
||||||
|
|
||||||
|
Communication
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Use [~motiejus/undocker@lists.sr.ht](mailto:~motiejus/undocker@lists.sr.ht) for
|
||||||
|
questions or patches. Subscribe [here][4].
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
-------
|
-------
|
||||||
|
|
||||||
@@ -121,3 +114,4 @@ MIT
|
|||||||
[1]: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
[1]: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||||
[2]: https://fly.io/blog/docker-without-docker/
|
[2]: https://fly.io/blog/docker-without-docker/
|
||||||
[3]: http://git.sr.ht/~motiejus/undocker
|
[3]: http://git.sr.ht/~motiejus/undocker
|
||||||
|
[4]: https://lists.sr.ht/~motiejus/undocker
|
||||||
|
|||||||
13
release
13
release
@@ -9,7 +9,14 @@ err() {
|
|||||||
git status --porcelain | grep -q "" &&
|
git status --porcelain | grep -q "" &&
|
||||||
err "working tree is dirty, commit your changes first."
|
err "working tree is dirty, commit your changes first."
|
||||||
|
|
||||||
[[ ! "$1" =~ ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] && \
|
# https://raimue.blog/2010/09/09/bash-for-loop-with-glob-patterns/
|
||||||
|
shopt -s nullglob
|
||||||
|
for file in sha256sum-*; do
|
||||||
|
err "found $file from previous release, delete it first"
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
|
||||||
|
[[ "$1" =~ ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] || \
|
||||||
err "arg1 accepts the following formats: v1.0 v1.0.0"
|
err "arg1 accepts the following formats: v1.0 v1.0.0"
|
||||||
|
|
||||||
git tag | grep -q "^$1$" &&
|
git tag | grep -q "^$1$" &&
|
||||||
@@ -17,7 +24,7 @@ git tag | grep -q "^$1$" &&
|
|||||||
|
|
||||||
last_tag=$(git tag | tail -1)
|
last_tag=$(git tag | tail -1)
|
||||||
|
|
||||||
make -B -j"$(nproc)" VSN="$1" sha256sum.txt.asc
|
make -B -j"$(nproc)" VSN="$1" sha256sum-asc
|
||||||
|
|
||||||
{
|
{
|
||||||
echo undocker "$1"
|
echo undocker "$1"
|
||||||
@@ -27,6 +34,6 @@ make -B -j"$(nproc)" VSN="$1" sha256sum.txt.asc
|
|||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo sha256sums of released binaries:
|
echo sha256sums of released binaries:
|
||||||
cat sha256sum.txt
|
cat sha256sum-*.txt
|
||||||
echo
|
echo
|
||||||
} | git tag -u motiejus@jakstys.lt -F - "$1"
|
} | git tag -u motiejus@jakstys.lt -F - "$1"
|
||||||
|
|||||||
@@ -146,9 +146,8 @@ func Flatten(rd io.ReadSeeker, w io.Writer) (_err error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// Avoiding use of multierr: if error is present, return
|
// Avoiding use of multierr: if error is present, return
|
||||||
// that. Otherwise return whatever `Close` returns.
|
// that. Otherwise return whatever `Close` returns.
|
||||||
err1 := tw.Close()
|
if err := tw.Close(); err != nil && _err == nil {
|
||||||
if _err == nil {
|
_err = err
|
||||||
_err = err1
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// iterate through all layers, all files, and write files.
|
// iterate through all layers, all files, and write files.
|
||||||
|
|||||||
Reference in New Issue
Block a user