2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: Apache-2.0
6 # This script is called by arv-migrate-docker19 to perform the actual migration
7 # of a single image. This works by running Docker-in-Docker (dnd.sh) to
8 # download the image using Docker 1.9 and then upgrading to Docker 1.13 and
9 # uploading the converted image.
11 # When using bash in pid 1 and using "trap on EXIT"
12 # it will sometimes go into an 100% CPU infinite loop.
14 # Using workaround from here:
16 # https://github.com/docker/docker/issues/4854
24 # -o pipefail use exit code from 1st failure in pipeline, not last
34 if [[ "$image_repo" = "<none>" ]] ; then
39 # Print free space in /var/lib/docker
40 function freespace() {
41 df -B1 /var/lib/docker | tail -n1 | sed 's/ */ /g' | cut -d' ' -f4
44 # Run docker-in-docker script and then wait for it to come up
45 function start_docker {
46 /root/dnd.sh $graph_driver &
47 for i in $(seq 1 10) ; do
48 if docker version >/dev/null 2>/dev/null ; then
56 # Kill docker from pid then wait for it to be down
57 function kill_docker {
58 if test -f /var/run/docker.pid ; then
59 kill $(cat /var/run/docker.pid)
61 for i in $(seq 1 10) ; do
62 if ! docker version >/dev/null 2>/dev/null ; then
70 # Ensure that we clean up docker graph and/or lingering cache files on exit
73 rm -rf /var/lib/docker/*
74 rm -rf /root/.cache/arvados/docker/*
75 echo "Available space after cleanup is $(freespace)"
82 echo "Initial available space is $(freespace)"
84 arv-get $image_tar_keepref | docker load
87 docker tag $image_id $image_repo:$image_tag
93 echo "Available space after image load is $(freespace)"
96 dpkg -i libltdl7_2.4.2-1.11+b1_amd64.deb docker-engine_1.13.1-0~debian-jessie_amd64.deb
98 echo "Available space after image upgrade is $(freespace)"
104 if [[ "$image_repo" = "none" ]] ; then
105 image_repo=$(docker images -a --no-trunc | sed 's/ */ /g' | grep ^none | cut -d' ' -f3)
109 UUID=$(arv-keepdocker --force-image-format --project-uuid=$project_uuid $image_repo $image_tag)
111 echo "Available space after arv-keepdocker is $(freespace)"
113 echo "Migrated uuid is $UUID"