Use docker import/export to make image smaller
Using docker export gives us only the top filesystem layer and not all the layers used to build. Resulting image is about 20% smaller. Further optimizations will be made in future commits via removing build time deps and temporary files in the Dockerfile. Change-Id: I0f7ad6d00c6f47836dcd71b05907076701bb2789 (cherry picked from commit 99dba22eaa3961234abde1294e55026fd2cc9d4d)
This commit is contained in:
parent
8edf98a199
commit
5516cd5baf
|
@ -4,7 +4,7 @@ docker:
|
|||
./docker_build.bash
|
||||
|
||||
coreos:
|
||||
mkdir UPLOAD
|
||||
mkdir -p UPLOAD
|
||||
./coreos-oem-inject.py oem UPLOAD
|
||||
|
||||
clean:
|
||||
|
@ -12,6 +12,7 @@ clean:
|
|||
rm -f oem/container.tar.gz
|
||||
rm -f UPLOAD/coreos_production_pxe_image-oem.cpio.gz
|
||||
rm -f UPLOAD/coreos_production_pxe.vmlinuz
|
||||
rm -rf ../.image_cache
|
||||
|
||||
docker_clean:
|
||||
./docker_clean.bash
|
||||
|
|
|
@ -8,7 +8,7 @@ import tempfile
|
|||
import shutil
|
||||
from plumbum import local, cmd
|
||||
|
||||
COREOS_VERSION="dev-channel"
|
||||
COREOS_VERSION="197.0.0"
|
||||
|
||||
COREOS_ARCH="amd64-generic"
|
||||
COREOS_BASE_URL="http://storage.core-os.net/coreos/{}/{}".format(COREOS_ARCH, COREOS_VERSION)
|
||||
|
|
|
@ -23,4 +23,7 @@ cd -
|
|||
# TODO: Investigate running a container and using "export" to flatten the
|
||||
# image to shrink the CoreOS fs size. This will also require run.sh to
|
||||
# use docker import instead of docker load as well.
|
||||
docker save oemdocker | gzip > ${OUTPUT_FILE}
|
||||
docker run oemdocker echo PICKME
|
||||
CONTAINER=`docker ps -a |grep PICKME|awk '{print $1}'|head -n1`
|
||||
echo $CONTAINER
|
||||
docker export $CONTAINER | gzip > ${OUTPUT_FILE}
|
||||
|
|
|
@ -24,8 +24,7 @@ while [ ! -e /var/run/docker.sock ]; do
|
|||
sleep 1;
|
||||
done
|
||||
|
||||
# TODO: Use docker import (and export the image) to shrink image size
|
||||
docker load < container.tar.gz
|
||||
docker import - oemdocker:latest < container.tar.gz
|
||||
|
||||
systemctl enable --runtime /usr/share/oem/system/*
|
||||
systemctl start ironic-python-agent.service
|
||||
|
|
Loading…
Reference in New Issue