3 # This script is called by arv-migrate-docker19 to perform the actual migration
4 # of a single image. This works by running Docker-in-Docker (dnd.sh) to
5 # download the image using Docker 1.9 and then upgrading to Docker 1.13 and
6 # uploading the converted image.
8 # When using bash in pid 1 and using "trap on EXIT"
9 # it will sometimes go into an 100% CPU infinite loop.
11 # Using workaround from here:
13 # https://github.com/docker/docker/issues/4854
21 # -o pipefail use exit code from 1st failure in pipeline, not last
31 if [[ "$image_repo" = "<none>" ]] ; then
36 # Print free space in /var/lib/docker
37 function freespace() {
38 df -B1 /var/lib/docker | tail -n1 | sed 's/ */ /g' | cut -d' ' -f4
41 # Run docker-in-docker script and then wait for it to come up
42 function start_docker {
43 /root/dnd.sh $graph_driver &
44 for i in $(seq 1 10) ; do
45 if docker version >/dev/null 2>/dev/null ; then
53 # Kill docker from pid then wait for it to be down
54 function kill_docker {
55 if test -f /var/run/docker.pid ; then
56 kill $(cat /var/run/docker.pid)
58 for i in $(seq 1 10) ; do
59 if ! docker version >/dev/null 2>/dev/null ; then
67 # Ensure that we clean up docker graph and/or lingering cache files on exit
70 rm -rf /var/lib/docker/*
71 rm -rf /root/.cache/arvados/docker/*
72 echo "Available space after cleanup is $(freespace)"
79 echo "Initial available space is $(freespace)"
81 arv-get $image_tar_keepref | docker load
84 docker tag $image_id $image_repo:$image_tag
90 echo "Available space after image load is $(freespace)"
93 dpkg -i libltdl7_2.4.2-1.11+b1_amd64.deb docker-engine_1.13.1-0~debian-jessie_amd64.deb
95 echo "Available space after image upgrade is $(freespace)"
101 if [[ "$image_repo" = "none" ]] ; then
102 image_repo=$(docker images -a --no-trunc | sed 's/ */ /g' | grep ^none | cut -d' ' -f3)
106 UUID=$(arv-keepdocker --force-image-format --project-uuid=$project_uuid $image_repo $image_tag)
108 echo "Available space after arv-keepdocker is $(freespace)"
110 echo "Migrated uuid is $UUID"