Merge "Add tar as an output type"
This commit is contained in:
commit
20cb5927d2
@ -23,7 +23,9 @@ What tools are there?
|
||||
Element dependencies are automatically included. Support for other
|
||||
architectures depends on your environment being able to run binaries of that
|
||||
platform. For instance, to enable armhf on Ubuntu install the qemu-user-static
|
||||
package.
|
||||
package. The default output format from disk-image-create is qcow2. To instead
|
||||
output a tarball pass in "-t tar". This tarball could then be used as an image
|
||||
for a linux container(see docs/docker.md).
|
||||
|
||||
* ramdisk-image-create -o filename {element} [{element} ...] : Create a kernel+
|
||||
ramdisk pair for running maintenance on bare metal machines (deployment,
|
||||
|
@ -46,6 +46,7 @@ function show_options () {
|
||||
echo "Options:"
|
||||
echo " -a i386|amd64|armhf -- set the architecture of the image(default amd64)"
|
||||
echo " -o imagename -- set the imagename of the output image file(default image)"
|
||||
echo " -t qcow2|tar -- set the imagetype of the output image file(default qcow2)"
|
||||
echo " -x -- turn on tracing"
|
||||
echo " -u -- uncompressed; do not compress the image - larger but faster"
|
||||
echo " -c -- clear environment before starting work"
|
||||
@ -83,7 +84,7 @@ function show_options () {
|
||||
|
||||
INSTALL_PACKAGES=""
|
||||
COMPRESS_IMAGE="true"
|
||||
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize: -n $SCRIPTNAME -- "$@"`
|
||||
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize: -n $SCRIPTNAME -- "$@"`
|
||||
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
@ -93,6 +94,7 @@ while true ; do
|
||||
case "$1" in
|
||||
-a) export ARCH=$2; shift 2 ;;
|
||||
-o) export IMAGE_NAME=$2; shift 2 ;;
|
||||
-t) export IMAGE_TYPE=$2; shift 2 ;;
|
||||
-h|--help) show_options; exit 0;;
|
||||
-x) shift; set -x;;
|
||||
-u) shift; export COMPRESS_IMAGE="";;
|
||||
@ -181,9 +183,15 @@ mount_proc_dev_sys
|
||||
run_d_in_target finalise
|
||||
finalise_base
|
||||
|
||||
if [ "$IMAGE_TYPE" == "tar" ]; then
|
||||
sudo tar -C ${TMP_BUILD_DIR}/mnt -cf $IMAGE_NAME.tar --exclude ./sys \
|
||||
--exclude ./proc --xattrs --xattrs-include=\* .
|
||||
sudo chown $USER: $IMAGE_NAME.tar
|
||||
fi
|
||||
|
||||
unmount_image
|
||||
|
||||
if [ "$IS_RAMDISK" == "0" ]; then
|
||||
if [ "$IS_RAMDISK" == "0" -a "$IMAGE_TYPE" != "tar" ]; then
|
||||
compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
|
||||
else
|
||||
# This is a ramdisk build, we have already extracted the kernel and ramdisk
|
||||
|
18
docs/docker.md
Normal file
18
docs/docker.md
Normal file
@ -0,0 +1,18 @@
|
||||
Creating Docker Images
|
||||
======================
|
||||
|
||||
disk-image-create can be used to create a tarball suitable to be imported as a
|
||||
docker image. To do this you can change the output of disk-image-create to tar
|
||||
with the -t flag and run docker e.g.
|
||||
|
||||
```
|
||||
disk-image-create -o image -t tar fedora selinux-permissive
|
||||
```
|
||||
|
||||
Assuming you have docker running and have permission to use it, the tarball can
|
||||
be imported into docker and run.
|
||||
|
||||
```
|
||||
docker import - image:test1 < image.tar
|
||||
docker run -t -i image:test1 /bin/bash
|
||||
```
|
Loading…
Reference in New Issue
Block a user