Docker Community Forums

Share and learn in the Docker community.

Change Docker Image Directory for Mac?


(Napjon) #1

Hi,

I’m just started using Docker by installing Docker for Mac. There are no container or images.
How do I change images/container default storage directory to another location?

I’ve read How do I change the Docker image installation directory?
But I’m not sure if it’s applicable to OS X.


(Codingmaster) #2

I’m also looking for the solution of this question.
When you have installed the docker via docker toolbox. The docker-machine VM is called “default” and it exists in /Users//.docker/machine/machines/default/ directory.


(Kendallarneaud) #3

+1 bump. Did anyone figure this out?


(Michael Chiang) #4

Hi,

That link talks about Docker Machine.

Docker for Mac takes care of this for you. This is stored inside the VM that we create, and currently there isn’t a way to change this.

May I know what use case this is for? I’d like to document this.


(Jonathan Knight) #5

Hi,

One reason I’d like to move them is just to stop my main drive filling with stuff. Being able to relocate the images, or the whole VM to another drive would be useful for those with small main drives and huge external drives.


(Aareetcm) #6

+1, voting for this as well - I quickly run out of disk space on my MacBook Air when trying to bring up containers.


(Kendallarneaud) #7

+1 what they said. I have been experimenting with Kitematic to achieve this but with minimal success thus far


(Mbklein) #8

What about simply moving ~/Library/Containers/com.docker.docker to another volume and symlinking it back to ~/Library/Containers/com.docker.docker?


(Kendallarneaud) #10

Well what about adopting the ENV variables the same way docker toolbox would. ? I’m surprised that something like this is such a debate. Disk space is really an important factor and it think its obvious that one would want to be able to preserve their device as much as possible. I think being able to configure how a software uses up your disk space should be something taken into consideration when devising these tooling apparatuses.


(Alvico) #11

Yes please, enable a way to changing this, it’s killing my main disk as well. What mbklein proposed is a nice workaround “patch” but not a real fix to a critical feature.


(Tofdocker) #12

Hi,
Like other my main disc on my mac is full I wish I could move the images on another disc.


(Drwin) #13

Just to confirm, the proposed symlinking solution worked for me.

> sw_vers
ProductName:	Mac OS X
ProductVersion:	10.12.1
BuildVersion:	16B2555

> docker --version
Docker version 1.12.3, build 6b644ec

> rsync --version
rsync  version 3.1.2  protocol version 31
...

instead of cp -R com.docker.docker /Volumes/..., I had to do rsync -a com.docker.docker /Volumes/...

some files are “socket” files and they refused to be copied via cp.


(Sebastian Gabrisch) #14

Yep, just to confirm a second time - that’s a working solution…

Actually it’s fine to just move the Docker Image to the location of your choice and symlinking that. Then you don’t run into the socket errors mentioned by drwin:

mv /Users/<username>/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 /<path-of-your-choice>/
ln -s /<path-of-your-choice>/Docker.qcow2 /Users/<username>/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

(Max Frigge) #15

When using Docker for Mac, there is a preference for the the storage location in the advanced tab. You change the location and confirm with Apply & Restart. Docker for Mac will move the storage archive and take care of the rest. This can obviously take some time depending on storage size and disk speed… be patient.


(Jonas) #16

this is working solution. thank you!


(Experimentaldata) #17

I used the move Disk image location option in Docker Preferences (Version 18.03.1-ce-mac65 (24312)) and after a restart Docker doesn’t find the images. Running docker images in Terminal doesn’t return anything other than the header fields. I moved the images to an external Transcend JetDrive to reduce the container build up on the Mac drive. Is there something else I need to do to point Docker to the images? I was thinking of uninstalling Docker then reinstalling and before creating anything change the image location but this is a bit more drastic than what I was hoping to do. Thanks!


(09wattry) #18

Thanks, I was able to set this up using your suggestion. I took some time to document the process for anyone that comes in search of answers. How to store docker images and containers on an external drive.