DockerでMacのDiskがいっぱいになった

# 現象

気づかぬうちに、MacのDiskが蝕まれていた

# Check

homeの下をチェック

```
sudo du -x -h -d 2 /Users/masato-naka/ | sort -h -r | head -30
...
109G	/Users/masato-naka/
 80G	/Users/masato-naka//Library
 54G	/Users/masato-naka//Library/Containers
 17G	/Users/masato-naka//Library/Caches
...
```

なぜかLibrary/Containersの下が54Gもある

```
sudo du -x -h -d 2 /Users/masato-naka//Library/Containers/com.docker.docker/Data | sort -h -r | head -30
 50G	/Users/masato-naka//Library/Containers/com.docker.docker/Data/vms/0
 50G	/Users/masato-naka//Library/Containers/com.docker.docker/Data/vms
 50G	/Users/masato-naka//Library/Containers/com.docker.docker/Data
 60M	/Users/masato-naka//Library/Containers/com.docker.docker/Data/log
 41M	/Users/masato-naka//Library/Containers/com.docker.docker/Data/log/vm
 19M	/Users/masato-naka//Library/Containers/com.docker.docker/Data/log/host
 20K	/Users/masato-naka//Library/Containers/com.docker.docker/Data/tasks
```

Dockerの仕業だった

以下のコマンドでチェックしてみるとVolumeが大量にありそうだった

```
docker system df -v
```

# 解決方法

以下のコマンドでvolumeをprune

```
docker volume prune -f
...
Total reclaimed space: 44.06GB
```

これでもまだ 50Gは消えていない

[Reset disk image] を押してすべて消す

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/7059/4e1bbb2f-13b8-74b0-a659-f1edf504194b.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/7059/c023f8fc-b83d-d5f4-8014-8ac63211f094.png)


```
sudo du -x -h -d 2 /Users/masato-naka//Library/Containers/com.docker.docker/ | sort -h -r | head -30
 70M	/Users/masato-naka//Library/Containers/com.docker.docker//Data
 70M	/Users/masato-naka//Library/Containers/com.docker.docker/
 63M	/Users/masato-naka//Library/Containers/com.docker.docker//Data/log
164K	/Users/masato-naka//Library/Containers/com.docker.docker//Data/vms
 20K	/Users/masato-naka//Library/Containers/com.docker.docker//Data/tasks
```

開放できた！

df で確認するとほぼ全部なくなってる!

```
docker system df -v
Images space usage:

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE                SHARED SIZE         UNIQUE SIZE         CONTAINERS
k8s.gcr.io/kube-controller-manager   v1.15.5             1399a72fa1a9        5 months ago        158.8MB             42.32MB             116.5MB             0
k8s.gcr.io/kube-proxy                v1.15.5             cbd7f21fec99        5 months ago        82.41MB             42.32MB             40.09MB             0
k8s.gcr.io/kube-apiserver            v1.15.5             e534b1952a0d        5 months ago        206.9MB             42.32MB             164.6MB             0
k8s.gcr.io/kube-scheduler            v1.15.5             fab2dded59dd        5 months ago        81.11MB             42.32MB             38.79MB             0
k8s.gcr.io/coredns                   1.3.1               eb516548c180        14 months ago       40.3MB              0B                  40.3MB              0
k8s.gcr.io/etcd                      3.3.10              2c4adeb21b4f        15 months ago       258.1MB             0B                  258.1MB             0
k8s.gcr.io/pause                     3.1                 da86e6ba6ca1        2 years ago         742.5kB             0B                  742.5kB             0

Containers space usage:

CONTAINER ID        IMAGE               COMMAND             LOCAL VOLUMES       SIZE                CREATED             STATUS              NAMES

Local Volumes space usage:

VOLUME NAME         LINKS               SIZE

Build cache usage: 0B

CACHE ID            CACHE TYPE          SIZE                CREATED             LAST USED           USAGE               SHARED
```

# 参考

[ローカル環境の docker を断捨離するためにやること](https://qiita.com/tasmania/items/d759600b3e81924167d0)