From 48d628ae3e83abb91326126d4a5fde31ac6e2631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Michalak-Szmaci=C5=84ski?= <25711553+DamMicSzm@users.noreply.github.com> Date: Thu, 21 Jul 2022 23:48:00 +0200 Subject: [PATCH] Fix storage location of Docker images and containers for Mac or linux (#21046) * Fix storage location of Docker images and containers for osx or linux This will fix information about used memory space when build image of docker on osx host machine. Docker has another directory on linux and osx. * Fixed styling problem * Improved system checking and path mapping for docker volume --- integrations/docker/build.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/integrations/docker/build.sh b/integrations/docker/build.sh index 6c4a1a2dc26f98..cb52fe60746e89 100755 --- a/integrations/docker/build.sh +++ b/integrations/docker/build.sh @@ -33,6 +33,12 @@ IMAGE=${DOCKER_BUILD_IMAGE:-$(basename "$(pwd)")} # version VERSION=${DOCKER_BUILD_VERSION:-$(sed 's/ .*//' version)} +if [[ $OSTYPE == 'darwin'* ]]; then + DOCKER_VOLUME_PATH=~/Library/Containers/com.docker.docker/Data/vms/0/ +else + DOCKER_VOLUME_PATH=/var/lib/docker/ +fi + [[ ${*/--help//} != "${*}" ]] && { set +x echo "Usage: $me @@ -59,7 +65,7 @@ set -ex [[ -n $VERSION ]] || die "version cannot be empty" -mb_space_before=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}') +mb_space_before=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}') # go find and build any CHIP images this image is "FROM" awk -F/ '/^FROM connectedhomeip/ {print $2}' Dockerfile | while read -r dep; do @@ -92,8 +98,9 @@ docker image prune --force } docker images --filter=reference="$ORG/*" -df -h /var/lib/docker/ -mb_space_after=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}') +df -h "$DOCKER_VOLUME_PATH" +mb_space_after=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}') + printf "%'.f MB total used\n" "$((mb_space_before - mb_space_after))" exit 0