1
0
mirror of https://github.com/rancher/os.git synced 2025-09-02 15:24:32 +00:00

Fix image preloading

This commit is contained in:
Josh Curl
2016-08-21 22:51:01 -07:00
parent 7a1609a398
commit 5eda685ff5
4 changed files with 33 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
FROM rancher/os-base
RUN ln -sf /var/lib/rancher/docker/docker /usr/bin/docker
RUN ln -sf /var/lib/rancher/engine/docker /usr/bin/docker
COPY preload.sh /
CMD ["/preload.sh"]

View File

@@ -4,6 +4,12 @@ set -e
BASE=${1:-${PRELOAD_DIR}}
BASE=${BASE:-/mnt/preload}
if [ "${SYSTEM_IMAGES}" = "true" ]; then
docker_bin=system-docker
else
docker_bin=docker
fi
should_load() {
file=${1}
if [[ ${file} =~ \.done$ ]]; then echo false
@@ -26,7 +32,7 @@ if [ -d ${BASE} ]; then
if [[ ${file} =~ \.t?gz$ ]]; then CAT="${CAT} | gunzip"; fi
if [[ ${file} =~ \.t?xz$ ]]; then CAT="${CAT} | unxz"; fi
wait-for-docker
CAT="${CAT} | docker load"
CAT="${CAT} | ${docker_bin} load"
echo loading from ${path}
eval ${CAT} || :
touch ${path}.done || :

View File

@@ -253,6 +253,8 @@ rancher:
- system-volumes
preload-system-images:
image: {{.OS_REPO}}/os-preload:{{.VERSION}}{{.SUFFIX}}
environment:
- SYSTEM_IMAGES=true
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system

23
tests/preload_test.go Normal file
View File

@@ -0,0 +1,23 @@
package integration
import (
. "gopkg.in/check.v1"
)
func (s *QemuSuite) TestPreload(c *C) {
err := s.RunQemu()
c.Assert(err, IsNil)
s.CheckCall(c, `
docker pull busybox
sudo docker save -o /var/lib/rancher/preload/system-docker/busybox.tar busybox
sudo system-docker pull alpine
sudo system-docker save -o /var/lib/rancher/preload/docker/alpine.tar alpine`)
s.Reboot(c)
s.CheckCall(c, `
sleep 5
sudo system-docker images | grep busybox
docker images | grep alpine`)
}