Merge pull request #1201 from justincormack/newtools

Add new minimal init prototype and new tools
This commit is contained in:
Justin Cormack
2017-02-17 15:56:42 +00:00
committed by GitHub
17 changed files with 1437 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ FROM alpine:3.5
RUN \
apk update && apk upgrade && \
apk add \
bsd-compat-headers \
curl \
gcc \
git \

View File

@@ -0,0 +1,5 @@
FROM docker:1.13.1
COPY . ./
ENTRYPOINT ["/docker2tar.sh"]

29
tools/docker2tar/Makefile Normal file
View File

@@ -0,0 +1,29 @@
.PHONY: tag push
BASE=docker:1.13.1
IMAGE=docker2tar
default: push
hash: Dockerfile docker2tar.sh
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --entrypoint=/bin/sh --rm $(IMAGE):build -c 'cat $^ /usr/local/bin/* /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > $@
push: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
docker push mobylinux/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

43
tools/docker2tar/docker2tar.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/sh
set -e
# arguments is image name
IMAGE="$1"; shift
cd /tmp
# extract rootfs
EXCLUDE="--exclude .dockerenv --exclude Dockerfile \
--exclude dev/console --exclude dev/pts --exclude dev/shm \
--exclude etc/hostname --exclude etc/hosts --exclude etc/mtab --exclude etc/resolv.conf"
CONTAINER="$(docker create $IMAGE /dev/null)"
docker export "$CONTAINER" | tar -xf - $EXCLUDE
docker rm "$CONTAINER" > /dev/null
# these three files are bind mounted in by docker so they are not what we want
mkdir -p etc
cat << EOF > etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
cat << EOF > etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
EOF
printf 'moby' > etc/hostname
ln -s /proc/mounts etc/mtab
tar cf - .