Skip to content

Instantly share code, notes, and snippets.

@proppy
Last active August 1, 2016 13:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save proppy/20ca5dec630aafc1d35c to your computer and use it in GitHub Desktop.
Save proppy/20ca5dec630aafc1d35c to your computer and use it in GitHub Desktop.
isoc: yet another "standard" container format

isoc

isoc is yet another "standard" container format.

It brings together the best bits of Docker Image Specification 1.0 and App Container Specification 0.3.0+git into a comprehensive yet portable container archive format, at the cost of a "few" duplicated bytes.

Layout

An isoc image is a appc image embedded in a docker image, but also a docker image embedded in a appc image. Some people might describe it as an iso-contained container format.

example.isoc
  repositories
  manifest
  rootfs/VERSION
  rootfs/layer.tar
  rootfs/json
  rootfs/<files>
  rootfs/...

Implementation

This gist comes with a reference implementation called (or ciso) to create isoc images from rootfs tarballs.

Usage

cat rootfs.tar | NAME= COMMAND= ✂ > image.isoc

Example

$ git clone https://gist.github.com/20ca5dec630aafc1d35c.git; cd 20ca5dec630aafc1d35c
$ cat busybox.tar | NAME=isoc/hello COMMAND="/bin/echo make container not war" ./✂ > hello.isoc
$ docker load < hello.isoc
$ docker run isoc/hello
make container not war
$ rkt run hello.isoc
/etc/localtime is not a symlink, not updating container timezone.
make container not war
Sending SIGTERM to remaining processes...
Sending SIGKILL to remaining processes...
Unmounting file systems.
Unmounting /proc/sys/kernel/random/boot_id.
All filesystems unmounted.
Halting system.
#!/bin/bash
#
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
USAGE="NAME= COMMAND= ✂"
: ${NAME:?missing, USAGE: \"$USAGE\"}
: ${COMMAND:?missing, USAGE: \"$USAGE\"}
COMMAND=$(python -c "import json; print json.dumps(\"${COMMAND}\".split(' '))")
CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
ISOC_TEMP=$(mktemp -d /tmp/isoc.XXXX)
cat > $ISOC_TEMP/layer.tar
IMAGE_ID=$(shasum -a 256 $ISOC_TEMP/layer.tar | cut -f 1 -d ' ')
cat > $ISOC_TEMP/VERSION <<EOF
1.0
EOF
cat > $ISOC_TEMP/json <<EOF
{
"id": "${IMAGE_ID}",
"created": "${CREATED}",
"docker_version": "1.5.0",
"config": {
"cmd": ${COMMAND}
},
"architecture": "amd64",
"os": "linux"
}
EOF
cat > $ISOC_TEMP/repositories <<EOF
{
"${NAME}": {
"latest": "${IMAGE_ID}"
}
}
EOF
cat > $ISOC_TEMP/manifest <<EOF
{
"acKind": "ImageManifest",
"acVersion": "0.3.0",
"name": "${NAME}",
"labels": [
{ "name": "arch", "value": "amd64" },
{ "name": "os", "value": "linux" }
],
"app": {
"exec": ${COMMAND},
"user": "0",
"group": "0"
},
"annotations": [
{ "name": "created", "value": "${CREATED}" }
]
}
EOF
mkdir -p $ISOC_TEMP/rootfs
tar -C $ISOC_TEMP/rootfs -xf $ISOC_TEMP/layer.tar || true
mv $ISOC_TEMP/{json,VERSION,layer.tar} $ISOC_TEMP/rootfs
tar -C $ISOC_TEMP -cf - .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment