mirror of
https://github.com/docker/docs.git
synced 2026-03-29 15:28:51 +07:00
Docker for Mac: add page on disk space
The disk space usage of Docker on Mac has been difficult to manage and has confused lots of people, see https://github.com/docker/for-mac/issues/371 This patch adds a top-level section to the Docker for Mac docs alongside networking which explains - where the space has gone - how to reclaim some of it In future I'd like to add more about why some systems use `Docker.raw` and some `Docker.qcow2` but we're in a transitional state at the moment. It'll be simpler to explain after the next stable version has been released. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
BIN
docker-for-mac/images/settings-disk.png
Normal file
BIN
docker-for-mac/images/settings-disk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
88
docker-for-mac/space.md
Normal file
88
docker-for-mac/space.md
Normal file
@@ -0,0 +1,88 @@
|
||||
---
|
||||
description: Disk space
|
||||
keywords: mac, disk
|
||||
title: Disk space in Docker for Mac
|
||||
---
|
||||
|
||||
Docker for Mac stores Linux containers and images in a single large "disk image" file
|
||||
in the Mac filesystem. This is different to Docker on Linux which usually stores containers
|
||||
and images in the `/var/lib/docker` directory.
|
||||
|
||||
## Where is the "disk image" file?
|
||||
|
||||
To locate the "disk image" file, first click on the whale menu and then click on
|
||||
"Preferences...". When the preferences window appears, click on the "Disk" icon
|
||||
and then "Reveal in Finder":
|
||||
|
||||

|
||||
|
||||
The preferences window also shows how much disk space the file is currently consuming.
|
||||
In this example it is consuming only 2.4 GB out of a maximum of 64 GB.
|
||||
|
||||
Note that other tools may display the space usage of the file incorrectly.
|
||||
|
||||
## If the file is too big
|
||||
|
||||
If the file is too big, you can
|
||||
- move it to a bigger drive;
|
||||
- delete unnecessary containers and images; or
|
||||
- reduce the maximum size of the file.
|
||||
|
||||
### To move the file to a bigger drive
|
||||
|
||||
To move the file, open the "Preferences..." menu, click on the "Disk" icon and then click
|
||||
on "Move disk image". Do not move the file directly in the finder or Docker for Mac will
|
||||
lose track of it.
|
||||
|
||||
### To delete unnecessary containers and images
|
||||
|
||||
To check whether you have too many unnecessary containers and images, first list images
|
||||
with:
|
||||
```bash
|
||||
$ docker image ls
|
||||
```
|
||||
then list containers with:
|
||||
```bash
|
||||
$ docker container ls -a
|
||||
```
|
||||
|
||||
If there are lots of unneeded objects, try the command
|
||||
```bash
|
||||
$ docker system prune
|
||||
```
|
||||
This will remove all stopped containers, unused networks, dangling images and build cache.
|
||||
|
||||
Note that it may take a few minutes before space becomes free on the host depending
|
||||
on what format the "disk image" file is in:
|
||||
- If the file is named `Docker.raw`: space on the host should be reclaimed within a few
|
||||
seconds.
|
||||
- If the file is named `Docker.qcow2`: space will be freed by a background process after
|
||||
a few minutes.
|
||||
|
||||
Note that space is only freed when images are deleted. Space is not freed automatically
|
||||
when files are deleted inside running containers. To trigger a space reclamation at any
|
||||
point, use the command:
|
||||
|
||||
```
|
||||
$ docker run --privileged --pid=host justincormack/nsenter1 /sbin/fstrim /var/lib/docker
|
||||
```
|
||||
|
||||
Note that many tools will report the maximum file size, not the actual file size.
|
||||
To query the actual size of the file on the host from a terminal, use:
|
||||
```bash
|
||||
$ cd ~/Library/Containers/com.docker.docker/Data
|
||||
$ cd vms/0 # or com.docker.driver.amd64-linux
|
||||
$ ls -klsh Docker.raw
|
||||
2333548 -rw-r--r--@ 1 akim staff 64G Dec 13 17:42 Docker.raw
|
||||
```
|
||||
In this example the actual size of the disk is `2333548` KB, whereas the maximum size
|
||||
of the disk is `64` GB.
|
||||
|
||||
### To reduce the maximum size of the file
|
||||
|
||||
To reduce the maximum size of the file, first click on the whale menu and then click on
|
||||
"Preferences...". When the preferences window appears, click on the "Disk" icon.
|
||||
The preferences window contains a slider which allows the maximum disk size to be set.
|
||||
If the maximum size is reduced, the current file will be deleted and therefore all
|
||||
containers and images will be lost.
|
||||
|
||||
Reference in New Issue
Block a user