Accessing persistant volumes in Docker Desktop for Mac
As I was getting some work done, I came across an edge case the other night where I needed to view the contents of a file in a Docker volume that was running on my Mac.
Unlike a Linux box, you can not navigate directly to /var/lib/docker/volumes
.
On a Mac, You have to jump through a few steps outlined below:
- We will "Screen to" a background VM running on your Mac.
- You will run:
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
- You will run:
- It's going to return a blank screen, just hit enter a few times and you'll see:
docker-desktop:~#
- Now just like on a Linux box, navigate to:
/var/lib/docker/volumes/
- You can edit the files and folders like normal
- To exit
ctrl-a
andd
Just like how you would exit a normal screen session
Hopefully this helps! I know I will be revisiting this article the next time I need to do this!