【运行】
docker run -i -t 镜像名 /bin/bash
【报错】
docker: write /var/lib/docker/tmp/GetImageBlob167182478: no space left on device.
【解决方案1】更新docker.serive文件——未解决
ubuntu - Docker error : no space left on device - Stack Overflowhttps://stackoverflow.com/a/56126715
If you are facing this issue even after below command:
docker system prune --all
The solution which worked finally:
- docker info
- To check current docker storage driver
- Mine was : Storage Driver: devicemapper; If you have storage driver as overlay2 nothing to worry about. Solution will still work for you.
- df -h
- This is to check the available file systems on machine and the path where they are mounted. Two mounted path to have a note:
- /dev/mapper/rootvg-var 7.6G 1.2G 6.1G 16% /var
- /dev/mapper/rootvg-apps 60G 9.2G 48G 17% /apps
- Note- By default docker storage path is /var/lib/docker. It has available space ~6 GB and hence all the space related issues. So basically, I have to move default storage to some other storage where available space is more. For me its File sysyem path '/dev/mapper/rootvg-apps' which is mounted on /apps. Now task is to move /var/lib/docker to something like /apps/newdocker/docker.
- mkdir /apps/newdocker/docker
- chmod -R 777 /apps/newdocker/docker
- Update docker.serive file on linux which resides under: /usr/lib/systemd/system
- vi /usr/lib/systemd/system/docker.service
- if storage device is devicemapper , comment existing ExecStart line and add below under [Service]:
- ExecStart=
- ExecStart=/usr/bin/dockerd -s devicemapper --storage-opt dm.fs=xfs --storage-opt dm.basesize=40GB -g /apps/newdocker/docker --exec-opt native.cgroupdriver=cgroupfs
- Or if storage device is overlay2:
- just add -g /apps/newdocker/docker in the existing ExexStart statement.
- Something like ExecStart=/usr/bin/dockerd -g /apps/newdocker/docker -H fd:// --containerd=/run/containerd/containerd.sock
- rm -rf /var/lib/docker (It will delete all existing docker data)
- systemctl stop docker
- ps aux | grep -i docker | grep -v grep
- If no output has been produced by the above command, reload systemd daemon by below command.
- systemctl daemon-reload
- systemctl start docker
- docker info
- Check out the Data Space Available: 62.15GB after mouting to docker to new File system.
- DONE
【解决方案2】docker change root directory——已解决
- Stop the Docker services:
sudo systemctl stop docker sudo systemctl stop docker.socket sudo systemctl stop containerd
- Create the necessary directory structure into which to move Docker Root by running the following command. This directory structure must reside on a file system with at least 50GB free disk space. Significantly more disk space may be required depending on your daily ingestion volumes and data retention policy:
sudo mkdir -p /new_dir_structure
- Move Docker Root to the new directory structure:
sudo mv /var/lib/docker /new_dir_structure
- Edit the file /etc/docker/daemon.json. If the file does not exist, create the file by running the following command:
Add the following information to this file:sudo vim /etc/docker/daemon.json
{ "data-root": "/new_dir_structure/docker” }
- After the /etc/docker/daemon.json file is saved and closed, restart the Docker services:
After you run the command, all Docker services through dependency management will restart.sudo systemctl start docker
- Validate the new Docker Root location:
docker info -f '{{ .DockerRootDir}}'