Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store Docker image files on external drive in macOS

Tags:

docker

macos

I'm using a Mac Book Pro with 128Gb disk. Is there any way to have the Docker images be stored on an external hard drive rather than on the Mac's main drive?

I don't have that much free space, and can't afford to remove any installed software. Ideally I'd like to have Docker fetch the images from an external drive. Can this be done using a symlink?

like image 400
Julio Costa Avatar asked Jul 05 '16 14:07

Julio Costa


People also ask

Where are Docker images stored on Mac?

On a Mac, the default location for Docker images is ~/Library/Containers/com. docker. docker/Data/vms/0/. Note than on Windows and Mac, Docker runs Linux containers in a virtual environment.

Where should I store Docker images?

If you use the default storage driver overlay2, then your Docker images are stored in /var/lib/docker/overlay2 . There, you can find different files that represent read-only layers of a Docker image and a layer on top of it that contains your changes.


1 Answers

Eventually figured out that docker can use a symlink. In a macOS setup the file that I want to place in an external drive is located at:

~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/

and is named

Docker.qcow2

Just move the file to an external disk drive (for instance) and create a symlink pointing to the new location.

like image 84
Julio Costa Avatar answered Sep 19 '22 13:09

Julio Costa