Where is /var/lib/docker on Mac/OS X
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
When working with Docker on Linux, users are accustomed to finding Docker's persistent storage data located at /var/lib/docker. However, on macOS, Docker runs differently. Docker Desktop for Mac uses a lightweight, hidden Linux virtual machine (VM) to run containers. This article delves into where the equivalent Docker data is stored on macOS, how to access it, and provides a technical explanation of Docker's unique architecture on macOS.
Docker on macOS: Architecture
Docker doesn't directly run on macOS due to its dependency on Linux kernel features. Instead, Docker Desktop for Mac utilizes a LinuxKit-based lightweight VM, named docker-desktop, that contains the Docker daemon and underpinning components. This setup makes it possible to run Linux containers as intended with Docker.
Docker File System Location on macOS
While on a Linux system, you'd find Docker's artifacts including images, containers, volumes, etc., under /var/lib/docker, this isn't the case for macOS:
- Engineering Approach: Docker manipulates a virtual file system within the VM to store data.
- Host Client Mapping: User commands from the Docker CLI on the host are translated to commands in the VM through a Unix socket.
On macOS, data isn't stored directly under a simple path like /var/lib/docker. Instead, it's tucked away within the following:
- VM Disk Image: Docker's virtual disk images are stored as files on the host's file system, usually located under:
- Volumes & File Storage: Docker volumes and other persistent data managed by Docker are inside the VM. They can be accessed using specific commands or methods discussed below.
Accessing Docker Data on macOS
Despite being encapsulated within the VM, there are ways to interact with the Docker storage:
Using Docker CLI for Data Inspection
- Inspect Containers and Volumes:
- Use
$ docker inspect <container_id>for detailed information about a given container. - Use
$ docker volume inspect <volume_name>to understand specific volume details.
- Execute Inside the VM:
- Docker for Mac includes a hidden command utility called
docker execthat allows users to run commands inside the VM. - You can SSH into Docker's backend environment for advanced data retrieval:
Mounting the Docker VM
For users who wish to explore Docker data more interactively:
- Use the Hyperkit tool (or similar) to interact with images.
- Export and then mount these images if necessary to access data directly without moving data onto the host.
Important Considerations
Running Docker on macOS involves nuances and considerations:
- Resource Limits: Docker Desktop settings allow users to limit CPU and memory allocations for the underlying VM.
- File Access: Users need to be aware of performance implications when using Docker volumes extensively, as file I/O operations are typically slower due to macOS's virtual file system bridge approach.
Summary Table
| Aspect | Linux filesystems | macOS (Docker Desktop) |
| Docker Storage Path | /var/lib/docker | ~/Library/Containers/com.docker.docker/ |
| Architecture | Native Linux Containers | Linux VM (Docker Desktop VM) |
| Data Access | Direct file path access | CLI & SSH Commands |
| Resource Management | Based on host OS | Managed through Docker Desktop GUI |
| Volume Performance | Native performance | Slower due to virtualized storage |
Conclusion
Understanding Docker's storage locations on macOS is crucial for effective management and debugging. Utilizing the tools and methods mentioned can allow users to better interact with Docker data, taking into account differences in architecture and resource handling. As you delve deeper into Docker on macOS, maintaining awareness of the VM layer and its resource allocations will lead to more efficient container management.
Related reading
- Where to find ca.crt in docker-for-desktop kubernetes?
- Which API Group in k8s
- Which kubernetes version is supported in docker version 18.09
- Why are Docker container images so large?
- Why are heaps in c implemented as algorithms instead of containers?
- Why are Kubernetes Custom Resource Definitions cluster wide
- Why do I have to always specify the range in STL''s algorithm functions explicitly, even if I want to work on the whole container?
- why do i need tty true in docker-compose.yml and other images do not?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.