---
# System prepended metadata

title: Docker Issue
tags: [Docker]

---

---
title: Docker issue
tags: Docker
description: Docker issue
---

# Docker Issue

### no space left on device
預設docker掛在 `/var/lib/docker` 目錄下，如果預設目錄空間不夠會遇到 no space left on device，解法為將docker掛載在另一個目錄下，假設要更改到docker路徑到`/home/data/docker`

先檢查docker掛載目錄
```
$ docker info | grep Root
```
![](https://hackmd.io/_uploads/ByJB3BQa2.png)

創建欲掛載目錄
```
$ mkdir /home/data/docker
$ rsync -avh /var/lib/docker/* /home/data/docker
```
修改 `/etc/docker/daemon.json`，加上 "data-root": "/home/data/docker"，修改完儲存檔案
```
$ nano /etc/docker/daemon.json
```
![](https://hackmd.io/_uploads/ry-z2BmT2.png)


```
$ systemctl daemon-reload
$ systemctl restart docker
```
docker 重掛目錄完成

## 參考
* https://juejin.cn/s/docker%20no%20space%20left%20on%20device%E8%A7%A3%E5%86%B3

## Thank you! :dash: 

You can find me on

- GitHub: https://github.com/shaung08
- Email: a2369875@gmail.com
