From 4ebd6b7e1deef617c42c70a031cdd0e96b449cb9 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 28 May 2015 15:28:50 -0700 Subject: [PATCH] Add support for docker volume Added an environment variable which can be used to pass in the docker volume for the container. This allows caching the pulled images between runs, preventing unnecessary image pulls. Signed-off-by: Derek McGowan (github: dmcgowan) --- contrib/docker-integration/README.md | 11 +++++++++-- contrib/docker-integration/run.sh | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/contrib/docker-integration/README.md b/contrib/docker-integration/README.md index 7e2ca11e..64c9c5a5 100644 --- a/contrib/docker-integration/README.md +++ b/contrib/docker-integration/README.md @@ -14,7 +14,7 @@ locally. *Building locally* ``` -docker build -t distribution/docker-integration . +$ docker build -t distribution/docker-integration . ``` ### Run script @@ -22,7 +22,14 @@ docker build -t distribution/docker-integration . Invoke the tests within Docker through the `run.sh` script. ``` -./run.sh +$ ./run.sh +``` + +Run with aufs driver and tmp volume +**NOTE: Using a volume will prevent multiple runs from needing to +re-pull images** +``` +$ STORAGE_DRIVER=aufs DOCKER_VOLUME=/tmp/volume ./run.sh ``` ## Running manually outside of Docker diff --git a/contrib/docker-integration/run.sh b/contrib/docker-integration/run.sh index 8d730b59..bd02b239 100755 --- a/contrib/docker-integration/run.sh +++ b/contrib/docker-integration/run.sh @@ -6,6 +6,11 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" # Root directory of Distribution DISTRIBUTION_ROOT=$(cd ../..; pwd -P) +volumeMount="" +if [ "$DOCKER_VOLUME" != "" ]; then + volumeMount="-v ${DOCKER_VOLUME}:/var/lib/docker" +fi + # Image containing the integration tests environment. INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration} @@ -14,9 +19,8 @@ INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration} #docker pull $INTEGRATION_IMAGE # Start the integration tests in a Docker container. -ID=$(docker run -d -t --privileged \ +ID=$(docker run -d -t --privileged $volumeMount \ -v ${DISTRIBUTION_ROOT}:/go/src/github.com/docker/distribution \ - -e "DOCKER_IMAGE=$DOCKER_IMAGE" \ -e "DOCKER_VERSION=$DOCKER_VERSION" \ -e "STORAGE_DRIVER=$STORAGE_DRIVER" \ -e "EXEC_DRIVER=$EXEC_DRIVER" \