/usr/bin/ch-docker2tar is in charliecloud 0.2.3~git20171120.1a5609e-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #!/bin/sh
LIBEXEC=/usr/lib/charliecloud
. ${LIBEXEC}/base.sh
set -e
#set -x
usage () {
cat 1>&2 <<EOF
Flatten a Docker image into a Charliecloud image tarball.
Usage:
$ $(basename $0) IMAGE OUTDIR
You must have sufficient privilege (via sudo) to run the Docker commands.
EOF
exit ${1:-1}
}
if [ "$1" = "--help" ]; then
usage 0
fi
if [ "$1" = "--version" ]; then
version
exit 0
fi
if [ "$#" -ne 2 ]; then
usage
fi
IMAGE=$1
OUTDIR=$2
TAR=$OUTDIR/$(echo $IMAGE | sed 's/\//./g').tar.gz
cid=$($DOCKER create --read-only $IMAGE)
#$DOCKER ps -af "id=$cid"
$DOCKER export $cid | $GZIP_CMD -6 > $TAR
$DOCKER rm $cid > /dev/null
# FIXME: This is brittle. We want the filename and size, but not the rest, so
# we can't just ask ls. Another option is stat and numfmt, but the latter may
# not be very portable.
ls -lh $TAR | awk '{ print $5,$9 }'
|