Where are images stored on Mac OS X?

You can use the docker inspect command to see the exact location of the data within the VM. You can also use the docker volume ls command to list the volumes.

For example: These are the volumes on my Mac right now:

$ docker volume ls

DRIVER    VOLUME NAME
local     lab-openshift_devcontainer_minikube-config
local     lab-openshift_devcontainer_postgres
local     vscode

Let’s say I want to know where the data for the vscode volume is being kept. I can use docker inspect to find that out.

$ docker inspect vscode
[
    {
        "CreatedAt": "2023-12-20T12:43:42Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/vscode/_data",
        "Name": "vscode",
        "Options": null,
        "Scope": "local"
    }
]

This is telling me that if I were to ssh into that VM, I can find the volume for vscode in the folder: /var/lib/docker/volumes/vscode/_data.

The easiest way to get at your data from your Mac, is to mount it to a container. For example like this:

$ docker run --rm -it -v vscode:/vscode ubuntu bash

root@b164e4417e24:/# ls -l /vscode
total 4
drwxr-xr-x 4 root root 4096 Dec 20 12:43 vscode-server

That command starts an ubuntu container and mounts the vscode volume at /vscode inside the container. Then I used the ls command to list it’s contents.

As you can see, there is a folder called vscode-server created in that volume which is mounted at /vscode. You can copy the data from the running ubuntu container with the docker cp command, or mount a local volume and copy to the data anywhere you want.

For example this will copy the contents of the folder into the current folder on your Mac:

docker run -d --name vscode -v vscode:/vscode busybox
docker cp vscode:/vscode .

That will leave you with a folder called vscode on your Mac with all the files that were in /vscode from the VM.

You will not see the data in the macOS Finder because it cannot be mounted to the macOS filesystem because it is inside the VM, but you can see the files from inside any container that has the volume mounted.

I’m guessing you want to edit files from outside the VM or running container. If that’s your intent, then I would use a filesystem mount and not have Docker manage the volume for you. That’s the whole purpose of filesystem mounts, i.e., you control where the data resides. Hope that helps.

~jr

1 Like