After running Docker for Mac for a long time, Docker keeps eating up disk space. Even though the containers and images are removed, the disk space is not reclaimed. The problem is the file
/Users/<username>/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 is too big. For my Mac, this file is about 46G. This is actually a known issue tracked in this GitHub issue. So far, we only have a workaround to fix this issue.
As mentioned in this comment, you need at least Docker for Mac version
17.06.0-ce-mac19 and run following commands.
Then force the trim operation to run.
Now we can wait and see the size of file
Docker.qcow2 shrinks. For my Mac, the size of this file shrinks to about 12G. The script actually creates the cron job to run the trim operation, so you need to do run this manually.
Hopefully there will be an easier solution for this issue in later Docker for Mac releases.