DEV Community

Cover image for How to Move Docker Data to an External Drive on MacOS
Felipe Belluco
Felipe Belluco

Posted on

How to Move Docker Data to an External Drive on MacOS

I recently decided to switch back to Apple after two years of working on a Windows PC. After watching several videos on YouTuber, I went with the entry-level Mac mini M4–16GB of RAM and 256GB of internal storage — and planned to use external storage for the heavy stuff.(I’ll list all the accessories I’m using at the end of the article.)

If you use Docker and have a small internal drive, you’ll eventually hit the dreaded “Your disk is almost full” error. That’s because Docker stores all images, volumes, and a large virtual disk file in its data directory, which can quickly eat up your space.

This guide walks you through the exact steps to move Docker’s data to an external drive — freeing up your internal storage without sacrificing performance or stability.


Identify the Docker Data Directory

Before we begin, it’s important to know what we are moving. We are not moving the Docker application itself, just the data directory, which contains all images, containers, volumes, etc. Moving the app itself can allegedly cause issues with updates and overall system stability, so we definitely want to avoid that.

The directory path depends on your version of Docker Desktop:

  • Version 4.3.0 and above: ~/Library/Group Containers/group.com.docker
  • Older versions: ~/Library/Containers/com.docker.docker/Data/vms/0/

Quit Docker Desktop

To ensure data integrity during the process, you must completely shut down the Docker Desktop Application. Click the Docker icon in the menu bar and select “Quit Docker Desktop”.

Move the Docker Data Directory

Now open Terminal (you’ll find it in /Application/Utilities) an run the following command to move the data to your external drive:

mv ~/Library/Group\ Containers/group.com.docker /Volumes/YourExternalDrive/DockerData/
Enter fullscreen mode Exit fullscreen mode

⚠️ Replace "YourExternalDrive" with the actual name of your drive, and "DockerData" with the desired folder name.

Depending on how much data Docker has stored, this might take a while.

Create a Symbolic Link

Now that the data is moved, we’ll create a symbolic link (symlink) from the original location to the new one. This makes Docker think its files are still in the default path.

In terminal, run:

ln -s /Volumes/YourExternalDrive/DockerData/group.com.docker ~/Library/Group\ Containers/group.com.docker
Enter fullscreen mode Exit fullscreen mode

⚠️ Ensure the paths here match the ones you used in the command above.

This command creates the necessary redirection for Docker to find its data.

Restart Docker and Verify

Start Docker Desktop again. It should now follow the symlink and use the data on your external drive.

To confirm everything’s working, run:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

If the container runs and outputs the “Hello from Docker!” message, you’re good to go. Alternatively, you can try starting any preexisting container directly from the Docker Desktop itself and see if everything runs as expected.

And that’s it! Docker is now running off your external drive, freeing up a significant amount of space on your internal storage.

Gear used

For reference, this guide was tested on a Mac Mini M4. The following accessories were used to expand the storage and provide seamless, high-performance experience.

Top comments (0)