docker-for-mac: add a FAQ about reducing the qcow2 size

In Docker for Mac 1.12 the only way to free space on the host is to
delete the qcow2 which means all containers and images have to be
rebuilt.

In Docker for Mac 1.13 there is preliminary support for shrinking the
qcow2 file non-destructively using "TRIM" (as also used on SSDs).
Unfortunately this isn't (yet) fully automatic -- it runs in the
background and requires the app to be occasionally restarted.

Related to [docker/for-mac#371]

Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
David Scott 2017-01-12 10:09:43 +00:00
parent 9157ec86aa
commit b9df8fd204
1 changed files with 32 additions and 0 deletions

View File

@ -140,6 +140,38 @@ Mac](http://container-solutions.com/adding-self-signed-registry-certs-docker-mac
Note that you need a Mac that supports hardware virtualization, which is most non ancient ones; i.e., use macOS `10.10.3+` or `10.11` (macOS Yosemite or macOS El Capitan). See also "What to know before you install" in [Getting Started](index.md).
### How do I reduce the size of Docker.qcow2?
By default Docker for Mac stores containers and images in a file
`~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2`.
This file grows on-demand up to a default maximum file size of 64GiB.
In Docker 1.12 the only way to free space on the host is to delete this file and
restart the app. Unfortunately this removes all images and containers.
In Docker 1.13 there is preliminary support for "TRIM" to non-destructively
free space on the host. First free space within the `Docker.qcow2` by
removing unneeded containers and images using
- `docker ps -a`: list all containers
- `docker image ls`: list all images
- `docker system prune`: (new in 1.13): deletes all stopped containers, all
volumes not used by at least one container and all images without at least one
referring container.
Note the `Docker.qcow2` will not shrink in size immediately. In 1.13 a background
`cron` job runs `fstrim` every 15 minutes. If the space needs to be reclaimed
sooner, run this command:
```
docker run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n fstrim /var
```
Once the `fstrim` has completed, restart the app. When the app
shuts down it will compact the file and the space will be freed. Note the app
will take longer to restart than usual because it must wait for the compaction
to complete.
### Do I need to uninstall Docker Toolbox to use Docker for Mac?
No, you can use these side by side. Docker Toolbox leverages a Docker daemon installed using `docker-machine` in a machine called `default`. Running `eval $(docker-machine env default)` in a shell sets DOCKER environment variables locally to connect to the default machine using Engine from Toolbox. To check whether Toolbox DOCKER environment variables are set, run `env | grep DOCKER`.