Last active
November 12, 2021 12:06
-
-
Save andresgutgon/e90dc3f5d2d61aac1d5dc062f982469c to your computer and use it in GitHub Desktop.
Docker inspect Volume bash function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker Inspect Volume | |
# :::::::::::::::::::::::: | |
# Found here | |
# https://www.freshblurbs.com/blog/2017/04/16/inspect-docker-volumes-on-mac.html | |
docker_inspect_volume () { | |
DOCKER_VOLUME_OUTPUT=$(docker volume inspect $1); | |
DOCKER_VOLUME_OUTPUT=$(echo "$DOCKER_VOLUME_OUTPUT" | grep -E '"Mountpoint": "[^,]*') | |
DOCKER_VOLUME_DIR=$(echo "$DOCKER_VOLUME_OUTPUT" | sed -r 's/("Mountpoint"\: ")(.*)(",)/\/docker\2/') | |
docker run --rm -it -w $DOCKER_VOLUME_DIR -v /:/docker alpine:edge | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Now in your terminal check the Docker volumes like this: | |
$ docker volume ls | |
DRIVER VOLUME NAME │Compressing objects: 100% (8/8), done. | |
local my_first_volume │Writing objects: 100% (8/8), 1.03 KiB | 1.03 MiB/s, done. | |
local my_second_volume │Total 8 (delta 6), reused 0 (delta 0), pack-reused 0 | |
local my_third_volume │remote: Resolving deltas: 100% (6/6), completed with 3 local objects. | |
# Once you know the one you want to enter use this function | |
$ docker_inspect_volume my_first_volume | |
/docker/var/lib/docker/volumes/my_first_volume/_data # INSIDE THE CONTAINER WATCHING the VOLUME : ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment