I had changed the directory to store containers and images as /data/docker.And it work successfully in the coming one year.
However, after I reboot the system (Ubuntu 16.04), a disk partition /dev/sdb4 was broken,which was mount to /data/docker. And the broken partition lead to the system come into emergency mode. I run a command fsck -y /dev/sdb4 to repair it and restart again.
After restarting,all work normally as before except docker. It is amazing that all my container and almost images were missing. When I run docker container ls -a,I got nothing. When I run docker images,I only got one list mysql 5.6 7edb93321b06 5 months ago 256MB.But I had 4 containers and some (more than one) images before. In other words,they were gone after reboot.
In addition,when I run sudo du -h /data/docker/volumes,I got:
6.8M /data/docker/volumes/b35a0a2be6a1d10693e891f0b5c7dfa6e27a34b6a61384e6db79ac06df4bde36/_data/mysql
636K /data/docker/volumes/b35a0a2be6a1d10693e891f0b5c7dfa6e27a34b6a61384e6db79ac06df4bde36/_data/performance_schema
116M /data/docker/volumes/b35a0a2be6a1d10693e891f0b5c7dfa6e27a34b6a61384e6db79ac06df4bde36/_data
116M /data/docker/volumes/b35a0a2be6a1d10693e891f0b5c7dfa6e27a34b6a61384e6db79ac06df4bde36
4.0K /data/docker/volumes/4bfb7ca010e869edd409ee14aa3a8b9ec70ec144a1b1586e792a8f87f9d5a9b2/_data
8.0K /data/docker/volumes/4bfb7ca010e869edd409ee14aa3a8b9ec70ec144a1b1586e792a8f87f9d5a9b2
4.0K /data/docker/volumes/d24ddf0126cef08bc3ff8bf75e79e76375b1e6cfa70c646d3173554d78555aeb/_data
8.0K /data/docker/volumes/d24ddf0126cef08bc3ff8bf75e79e76375b1e6cfa70c646d3173554d78555aeb
4.0K /data/docker/volumes/c22f29c1ab50c2973e6e1cc3e1ea64ad7a253741d44a290df3789fbf1e4c3a05/_data
8.0K /data/docker/volumes/c22f29c1ab50c2973e6e1cc3e1ea64ad7a253741d44a290df3789fbf1e4c3a05
4.0K /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data/#innodb_temp
84K /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data/sys
32K /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data/mysql
84K /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data/test
1.4M /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data/performance_schema
165M /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3/_data
165M /data/docker/volumes/985f51b406657eacbd70dfe7d0bd0502287c783a389ae34fa36d70b5c98e94a3
3.1G /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5/_data/newProject
6.8M /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5/_data/mysql
387M /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5/_data/project
636K /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5/_data/performance_schema
4.0G /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5/_data
4.0G /data/docker/volumes/b445468b292cff4531429b7a9883a825fc794327a46672ec518e7765050437e5
4.2G /data/docker/volumes
It means that some of data is not lost.
How can I repair it and find them back ?
Related
I enter # docker ps -s and it shows:
a658 gitlab/gitlab-ce:15.0.2-ce.0 ... 2.62MB (virtual 2.49GB)
But, when I enter # du -h /var/lib/docker/containers/ --max-depth=1 it shows:
20G /var/lib/docker/containers/a658
Gitlab container by default mounts /srv folder, there is a gitlab database, but it also weighs a little:
# du -h /srv/gitlab/ --max-depth=1
184K /srv/gitlab/config
428M /srv/gitlab/logs
2.8G /srv/gitlab/data
3.2G /srv/gitlab/
What could it be? This worries me very much, because the disk space of the host system is running out, and I cannot figure out what exactly is clogging all the space and where to look for it. At first I thought these were gitlab logs, but the corresponding folders weigh incomparably little. How can I check this and clean up the excess?
Going inside the container, I see that it also weighs very little:
# docker exec -it a658 bash
# du -h / --max-depth=1 | sort -h
0 /boot
0 /home
0 /media
0 /mnt
0 /proc
0 /srv
0 /sys
4.0K /tmp
12K /root
16K /run
28K /assets
1.5M /etc
7.7M /dev
90M /usr
2.5G /opt
3.2G /var
5.7G /
P.S. If it matters, host system on CentOS 7
I tried to find similar questions, but their answers does not helped me.
I am running a code optimizer for gzip.c in docker, in this process overlay grows infinitely large that eat up my disk.
root#id17:/var/lib/docker/overlay2/fe6987bf6e686e771ba7b08cda40aa477979512e182ad30120db037024638aa0# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sda5 245G 245G 0 100% /
...
overlay 245G 245G 0 100% /var/lib/docker/overlay2/fe6987bf6e686e771ba7b08cda40aa477979512e182ad30120db037024638aa0/merged
By using du -h --max-depth=1 I find it is diff and merged that consumed up my disk(is it?)
root#id17:/var/lib/docker/overlay2/fe6987bf6e686e771ba7b08cda40aa477979512e182ad30120db037024638aa0# du -h --max-depth=1
125G ./diff
129G ./merged
8.0K ./work
254G .
However, when I restart the dockersystemctl restart docker, it returned to normal.
root#eb9bf52aa3a3:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 245G 190G 43G 82% /
...
/dev/sda5 245G 190G 43G 82% /etc/hosts
...
root#id17:/var/lib/docker/overlay2/fe6987bf6e686e771ba7b08cda40aa477979512e182ad30120db037024638aa0# du -h --max-depth=1
125G ./diff
129G ./merged
8.0K ./work
254G .
It has come out for times and I cannot continue to do my work. So I really wonder how can I get out from this problem. Really thank you:-)
If the docker filesystem is growing, that often indicates container logs, or filesystem changes in the container. Logs you can see with docker logs and filesystem changes are shown with docker diff. Since you see a large diff folder, it's going to be the latter.
Those filesystem changes will survive a restart of the container, they get cleaned when the container is removed and replaced with a new container. So if restarting the container resolves it, my suspicion is your application is deleting the files on disk, but still has the file handles open to the kernel, possibly still writing to those file handles.
The other option is the stop or start of your application is deleting the files.
I want to use loop devices in a docker container locally. It means, when running a couple of container all of them should have for instance a /dev/loop0 connected to a file local in the container. I tried
[root#600bbfb452d1 /]# mknod /dev/loop20 b 7 20
[root#600bbfb452d1 /]# dd if=/dev/random of=loopfile1 bs=1M count=2
[root#600bbfb452d1 /]# losetup -a | grep 20
/dev/loop20: [0049]:3553002 (/loopfile1)
so far so good. But going back to host I can see:
[loewe#linux-2 ~]$ losetup -a | grep 20
/dev/loop20: []: (/loopfile1)
the loop device /dev/loop20 was also created in the hosts /dev - as my fear was because of the tmpfs mount - and worst the container local file "loopfile1" is attached to hosts loop dev.
I tries to umount the /dev filesystem in the container but didn't succeed (device busy but no proc visible with lsof).
Any idea what I am doing wrong?
BTW: using iscsi devices in a container should have the same problem.
Thanks Heiko
I have a server where I run some containers with volumes. All my volumes are in /var/lib/docker/volumes/ because docker is managing it. I use docker-compose to start my containers.
Recently, I tried to stop one of my container but it was impossible :
$ docker-compose down
[17849] INTERNAL ERROR: cannot create temporary directory!
So, I checked how the data is mounted on the server :
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 7,8G 0 7,8G 0% /dev
tmpfs 1,6G 1,9M 1,6G 1% /run
/dev/md3 20G 19G 0 100% /
tmpfs 7,9G 0 7,9G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 7,9G 0 7,9G 0% /sys/fs/cgroup
/dev/md2 487M 147M 311M 33% /boot
/dev/md4 1,8T 1,7G 1,7T 1% /home
tmpfs 1,6G 0 1,6G 0% /run/user/1000
As you can see, the / is only 20Go, so it is full and I can't stop my containers using docker-compose.
My questions are :
There is a simple solution to increase the available space in the
/, using /dev/md4 ?
Or can I move volumes to another place without losing data ?
This part of the Docker Daemon is confirgurable. Best practices would have you change the data folder; this can be done with OS-level Linux commands like a symlink... I would say it's better to actually configure the Docker Daemon to store the data elsewhere!
You can do that by editing the Docker command line (e.g. the systemd script that starts the Docker daemon), or change /etc/docker/daemon.json.
The file should have this content:
{
"data-root": "/path/to/your/docker"
}
If you add a new hard drive, partition, or mount point you can add it here and docker will store its data there.
I landed here as I had the very same issue. Even though some sources suggest you could do it with a symbolic link this will cause all kinds of issues.
Depending on the OS and Docker version I had malformed images, weird errors or the docker-daemon refused to start.
Here is a solution, but it seems it varies a little from version to version. For me the solution was:
Open
/lib/systemd/system/docker.service
And change this line
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
to:
ExecStart=/usr/bin/dockerd -g /mnt/WHATEVERYOUR/PARTITIONIS/docker --containerd=/run/containerd/containerd.sock
I solved it creating a symbolic link to a partition with bigger size:
ln -s /scratch/docker_meta /var/lib/docker
/scratch/docker_meta is the folder that I have in a bigger partition.
Do a bind mount.
For example, moving /docker/volumes to /mnt/large.
Append line into /etc/fstab.
/mnt/large /docker/volumes none bind 0 0
And then.
mv /docker/volumes/* /mnt/large/
mount /docker/volumes
Do not forget chown and chmod of /mnt/large first, if you are using non-root docker.
I changed Docker's storage base directory from /var/lib/docker to /home/docker by changing DOCKER_OPTIONS in /etc/default/docker as explained in this other question. After that, I rsynced the old /var/lib/docker to the new place.
Here is my Docker configuration file:
# Docker Upstart and SysVinit configuration file
# ....
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /home/docker"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
Everything was working fine after I rebooted. However, I started getting a "no space left on device" in my containers from time to time. When this error happens, if my container is up, I can't even do a mkdir. If the container is down and I try to start it, I get the following:
Error response from daemon: rpc error: code = 2 desc = "oci runtime
error: could not synchronise with container process: can't create
pivot_root dir , error mkdir .pivot_root: no space left on device"
However, I have space:
Filesystem Size Used Avail Use% Mounted on
udev 32G 4,0K 32G 1% /dev
tmpfs 6,3G 1,6M 6,3G 1% /run
/dev/sda1 92G 56G 32G 64% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
none 5,0M 0 5,0M 0% /run/lock
none 32G 472K 32G 1% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda5 1,6T 790G 762G 51% /home
I'm suspecting that perhaps I haven't done the storage migration correctly. Does someone know what might be happening?
Running out of disk space can also include inode limits. You can check those with df -i. This post on Unix.SE walks you through the steps required to increase the number of inodes available. Short of that, you can delete files to free up the inodes.
You can try cleaning up images that aren't in use. This fixed the problem for me:
docker images -aq -f 'dangling=true' | xargs docker rmi
As well as volumes. This will remove dangling volumes:
docker volume ls -q -f 'dangling=true' | xargs docker volume rm
https://success.docker.com/article/error-message-no-space-left-on-device-in-default-machine