mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
Try to determine the bind mount file for dockerinit
This patch adds code to the contrib/docker_cr.sh helper script for trying to determine the external bind mount file for dockerinit if the user has not explicitly specified it via the DOCKERINIT_BINARY environment variable. Signed-off-by: Saied Kazemi <saied@google.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
769d527876
commit
19ffca535c
@@ -24,15 +24,12 @@ set -o pipefail
|
||||
: ${DOCKER_BINARY=docker}
|
||||
: ${CRIU_IMG_DIR=${DOCKER_HOME}/criu_img}
|
||||
: ${CRIU_BINARY=criu}
|
||||
: ${DOCKERINIT_BINARY=}
|
||||
|
||||
declare -A BIND_MOUNT
|
||||
BIND_MOUNT[/etc/resolv.conf]=.ResolvConfPath
|
||||
BIND_MOUNT[/etc/hosts]=.HostsPath
|
||||
BIND_MOUNT[/etc/hostname]=.HostnamePath
|
||||
# since older versions of docker bind mount /.dockerinit but
|
||||
# the path cannot be queried by docker inspect, we have to
|
||||
# hard code it here
|
||||
BIND_MOUNT[/.dockerinit]="${DOCKER_HOME}/init/dockerinit-1.0.0"
|
||||
MOUNT_MAP_ARGS=()
|
||||
|
||||
#
|
||||
@@ -68,11 +65,34 @@ Environment:
|
||||
DOCKER_HOME (default ${DOCKER_HOME})
|
||||
CRIU_IMG_DIR (default ${CRIU_IMG_DIR})
|
||||
DOCKER_BINARY (default ${DOCKER_BINARY})
|
||||
DOCKERINIT_BINARY (default \${DOCKER_HOME}/init/dockerinit-<version>-dev)
|
||||
CRIU_BINARY (default ${CRIU_BINARY})
|
||||
EOF
|
||||
exit ${rv}
|
||||
}
|
||||
|
||||
#
|
||||
# If the user has not specified a bind mount file for the container's
|
||||
# /.dockerinit, try to determine it from the Docker version.
|
||||
#
|
||||
find_dockerinit() {
|
||||
local v
|
||||
|
||||
if [[ -z "${DOCKERINIT_BINARY}" ]]; then
|
||||
v=$("${DOCKER_BINARY}" --version | sed -e 's/.*version \(.*\),.*/\1/')
|
||||
DOCKERINIT_BINARY="${DOCKER_HOME}/init/dockerinit-${v}"
|
||||
elif [[ "${DOCKERINIT_BINARY}" != /* ]]; then
|
||||
DOCKERINIT_BINARY="${DOCKER_HOME}/init/${DOCKERINIT_BINARY}"
|
||||
fi
|
||||
|
||||
if [[ ! -x "${DOCKERINIT_BINARY}" ]]; then
|
||||
echo "${DOCKERINIT_BINARY} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BIND_MOUNT[/.dockerinit]="${DOCKERINIT_BINARY}"
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
local args
|
||||
local flags
|
||||
@@ -346,9 +366,11 @@ main() {
|
||||
local rv=0
|
||||
|
||||
parse_args "$@"
|
||||
find_dockerinit
|
||||
init_container_vars
|
||||
|
||||
${ECHO} "docker binary: ${DOCKER_BINARY}"
|
||||
${ECHO} "dockerinit binary: ${DOCKERINIT_BINARY}"
|
||||
${ECHO} "criu binary: ${CRIU_BINARY}"
|
||||
${ECHO} "image directory: ${CONTAINER_IMG_DIR}"
|
||||
${ECHO} "container root directory: ${CONTAINER_ROOT_DIR}"
|
||||
|
Reference in New Issue
Block a user