Skip to content

Commit 5d5faa5

Browse files
DamMicSzmpull[bot]
authored andcommitted
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
1 parent 5366002 commit 5d5faa5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

integrations/docker/build.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ IMAGE=${DOCKER_BUILD_IMAGE:-$(basename "$(pwd)")}
3333
# version
3434
VERSION=${DOCKER_BUILD_VERSION:-$(sed 's/ .*//' version)}
3535

36+
if [[ $OSTYPE == 'darwin'* ]]; then
37+
DOCKER_VOLUME_PATH=~/Library/Containers/com.docker.docker/Data/vms/0/
38+
else
39+
DOCKER_VOLUME_PATH=/var/lib/docker/
40+
fi
41+
3642
[[ ${*/--help//} != "${*}" ]] && {
3743
set +x
3844
echo "Usage: $me <OPTIONS>
@@ -59,7 +65,7 @@ set -ex
5965

6066
[[ -n $VERSION ]] || die "version cannot be empty"
6167

62-
mb_space_before=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}')
68+
mb_space_before=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}')
6369

6470
# go find and build any CHIP images this image is "FROM"
6571
awk -F/ '/^FROM connectedhomeip/ {print $2}' Dockerfile | while read -r dep; do
@@ -92,8 +98,9 @@ docker image prune --force
9298
}
9399

94100
docker images --filter=reference="$ORG/*"
95-
df -h /var/lib/docker/
96-
mb_space_after=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}')
101+
df -h "$DOCKER_VOLUME_PATH"
102+
mb_space_after=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}')
103+
97104
printf "%'.f MB total used\n" "$((mb_space_before - mb_space_after))"
98105

99106
exit 0

0 commit comments

Comments
 (0)