Update dockerctl copy to work with docker 1.8+
With CentOS7, we can no longer copy directly via devicemapper. Docker 1.8+ provides a cp function which can be used instead. This change updates the dockerctl script to leverage the docker cp ability rather than try and copy files directly via a devicemapper mount when docker 1.8+ is present. It will properly fall back to the devicemapper method if docker is less than 1.8. Change-Id: I8e81dd9e9d7eed76fea77a60ee602bef4925de20 Closes-Bug: #1524331
This commit is contained in:
parent
12fbb09d0b
commit
bc167a5d4a
|
@ -542,18 +542,28 @@ function copy_files {
|
||||||
fi
|
fi
|
||||||
container=$(echo $remote | cut -d':' -f1)
|
container=$(echo $remote | cut -d':' -f1)
|
||||||
remotepath=$(echo $remote | cut -d':' -f2-)
|
remotepath=$(echo $remote | cut -d':' -f2-)
|
||||||
if [[ ${CONTAINER_NAMES[@]} =~ .*${container}.* ]]; then
|
if [[ ! ${CONTAINER_NAMES[@]} =~ .*${container}.* ]]; then
|
||||||
cont_root=$(container_root $container)
|
echo "Unable to locate container named '${container}' to copy to/from."
|
||||||
if [ $? -ne 0 ];then return 1; fi
|
|
||||||
else
|
|
||||||
echo "Unable to locate container to copy to/from."
|
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
remote="${cont_root}/${remotepath}"
|
|
||||||
if [ "$method" = "push" ]; then
|
docker_version=$(get_docker_version)
|
||||||
cp -R $local $remote
|
if versioncmp_gte $docker_version '1.8'; then
|
||||||
|
remote="${CONTAINER_NAMES[$container]}:${remotepath}"
|
||||||
|
if [[ "$method" = "push" ]]; then
|
||||||
|
${DOCKER} cp $local $remote
|
||||||
|
else
|
||||||
|
${DOCKER} cp $remote $local
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
cp -R $remote $local
|
cont_root=$(container_root $container)
|
||||||
|
if [ $? -ne 0 ];then return 1; fi
|
||||||
|
remote="${cont_root}/${remotepath}"
|
||||||
|
if [[ "$method" = "push" ]]; then
|
||||||
|
cp -R $local $remote
|
||||||
|
else
|
||||||
|
cp -R $remote $local
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,3 +890,21 @@ function verify_disk_space {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function returns the version of docker using the docker -v command.
|
||||||
|
# docker -v returns 'Docker version <version>, build <hash>/<version>' so we
|
||||||
|
# pull the version off the end with awk
|
||||||
|
function get_docker_version {
|
||||||
|
echo $(${DOCKER} -v | awk '{ print $3 }' | sed -e 's/,//g')
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function is used to check that a version is greater than or equal to a
|
||||||
|
# specific version.
|
||||||
|
# Usage:
|
||||||
|
# versioncmp_gte <version> <version to compare to>
|
||||||
|
# Example
|
||||||
|
# versioncmp_gte 2.3.1 2.2.2 -> returns 0
|
||||||
|
# versioncmp_gte 2.1.1 2.2.2 -> returns 1
|
||||||
|
function versioncmp_gte {
|
||||||
|
[ "$1" = "$(echo -e "$1\n$2" | sort -V -r | head -n1)" ]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue