diff --git a/Dockerfile.test b/Dockerfile.test index 5741f73a7..431b204af 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -3,4 +3,4 @@ FROM justincormack/alpine-qemu COPY alpine/initrd.img.gz . COPY alpine/kernel/vmlinuz64 . -ENTRYPOINT [ "qemu-system-x86_64", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobytest=true", "-vnc", "none" ] +ENTRYPOINT [ "qemu-system-x86_64", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobyplatform=test", "-vnc", "none" ] diff --git a/alpine/Dockerfile b/alpine/Dockerfile index bc48356c5..f4728dd1f 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -68,7 +68,7 @@ COPY packages/userns/etc /etc/ COPY packages/vsudd/vsudd /sbin/ COPY packages/vsudd/etc /etc/ COPY packages/mobyconfig/mobyconfig /usr/bin/ -COPY packages/bootflag/bootflag /usr/bin/ +COPY packages/mobyplatform/mobyplatform /usr/bin/ COPY packages/gummiboot/gummiboot.tar.gz /usr/share/src/ COPY packages/oom/etc /etc/ COPY packages/9pmount-vsock/9pmount-vsock /sbin/ diff --git a/alpine/Dockerfile.efi b/alpine/Dockerfile.efi index 6f1140634..195114480 100644 --- a/alpine/Dockerfile.efi +++ b/alpine/Dockerfile.efi @@ -14,7 +14,7 @@ COPY packages/gummiboot/linuxx64.efi.stub /tmp/efi # Create a EFI boot file with kernel and initrd. From: # https://github.com/haraldh/mkrescue-uefi/blob/master/mkrescue-uefi.sh RUN cd /tmp/efi && \ - echo "earlyprintk=serial console=ttyS0" > cmdline.txt && \ + echo "earlyprintk=serial console=ttyS0 mobyplatform=windows" > cmdline.txt && \ objcopy \ --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ --add-section .cmdline=./cmdline.txt --change-section-vma .cmdline=0x30000 \ diff --git a/alpine/packages/bootflag/bootflag b/alpine/packages/bootflag/bootflag deleted file mode 100755 index d45372a6a..000000000 --- a/alpine/packages/bootflag/bootflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# Script to print values of arbitrary kvpairs the kernel was passed as command -# line parameters on boot. -# -# e.g. if kernel booted with cloud_provider=azure, 'bootflag cloud_provider' -# will return 'azure'. -# -# If multiple flags have the same key, it will return only the first one found. - -if [ $# -ne 1 ]; then - echo "Usage: bootflag [key]" - exit 1 -fi - -awk -v flag=$1 '{ - for(i = 1; i <= NF; i++) { - split($i, kvpair, "="); - if(kvpair[1] == flag) { - print kvpair[2]; - break; - } - } -}' /proc/cmdline diff --git a/alpine/packages/docker/etc/init.d/docker b/alpine/packages/docker/etc/init.d/docker index 6eff88ae0..d8381e046 100755 --- a/alpine/packages/docker/etc/init.d/docker +++ b/alpine/packages/docker/etc/init.d/docker @@ -15,9 +15,9 @@ start() # Only start with networking on cloud editions DOCKER_OPTS="${DOCKER_OPTS} -H unix:///var/run/docker.sock" - if [ ! -z $(bootflag cloud_provider) ] + if [ "$(mobyplatform)" == "aws" ] || [ "$(mobyplatform)" == "azure" ] then - # TODO: More elegant way to turn on "debug mode" + # TODO: Don't do this DOCKER_OPTS="${DOCKER_OPTS} -H 0.0.0.0:2375" fi diff --git a/alpine/packages/mobyplatform/mobyplatform b/alpine/packages/mobyplatform/mobyplatform new file mode 100755 index 000000000..4c1f3f365 --- /dev/null +++ b/alpine/packages/mobyplatform/mobyplatform @@ -0,0 +1,19 @@ +#!/bin/sh + +# Returns the platform we are running on + +# return the value matching the kvpair in the command line +kvpair() +{ +awk -v flag=$1 '{ + for(i = 1; i <= NF; i++) { + split($i, kvpair, "="); + if(kvpair[1] == flag) { + printf kvpair[2]; + break; + } + } +}' /proc/cmdline +} + +kvpair mobyplatform diff --git a/alpine/packages/proxy/etc/init.d/proxy b/alpine/packages/proxy/etc/init.d/proxy index 5d35a65c7..e10f416c8 100755 --- a/alpine/packages/proxy/etc/init.d/proxy +++ b/alpine/packages/proxy/etc/init.d/proxy @@ -2,11 +2,13 @@ depend() { - before docker + before docker } start() { + [ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0 + ebegin "Setting up proxy port service" mkdir -p /port @@ -32,6 +34,8 @@ start() stop() { + [ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0 + ebegin "Stopping proxy port service" [ -n "${PIDFILE}" ] || PIDFILE=/var/run/proxy-vsockd.pid diff --git a/alpine/packages/test/etc/init.d/test b/alpine/packages/test/etc/init.d/test index 3e43970c2..bbe73b390 100755 --- a/alpine/packages/test/etc/init.d/test +++ b/alpine/packages/test/etc/init.d/test @@ -7,7 +7,7 @@ depend() start() { - cat /proc/cmdline | grep -q 'mobytest' || exit 0 + [ "$(mobyplatform)" != "test" ] && exit 0 ebegin "Running tests" diff --git a/alpine/packages/vsudd/etc/init.d/vsudd b/alpine/packages/vsudd/etc/init.d/vsudd index 7e987ff24..afd486b5d 100755 --- a/alpine/packages/vsudd/etc/init.d/vsudd +++ b/alpine/packages/vsudd/etc/init.d/vsudd @@ -9,6 +9,8 @@ depend() start() { + [ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0 + ebegin "Starting vsock proxy" if [ -d /sys/bus/vmbus ]; then @@ -39,6 +41,8 @@ start() stop() { + [ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0 + ebegin "Stopping docker socket passthrough" [ -n "${PIDFILE}" ] || PIDFILE=/var/run/vsudd.pid diff --git a/docs/platforms.md b/docs/platforms.md new file mode 100644 index 000000000..e49102649 --- /dev/null +++ b/docs/platforms.md @@ -0,0 +1,23 @@ +## List of platforms + +These are the supported platforms. Each should boot with `mobyplatform=xxx` in the command line. + +### Desktop +`mac` +`windows` + +https://github.com/docker/pinata + +### Cloud +`aws` +`azure` + +https://github.com/docker/editions + +### Test +`test` + +https://github.com/docker/moby + +### Other +KVM/machine https://github.com/docker/moby/pull/225