Original link: https://www.dosk.win/2022/06/04/fu-pan-yi-ci-qun-hui-de-btrfs-docker-dind-yin-fa-de-zai-nan/
background
- I mainly use
k3s
to managehomelab
now, but Synology’s kernel lacks complete support for functions such ascgroup v2
andoverlayfs
, sodocker-compose
is the main one on Synology - Synology deploys three main things:
gitea
+drone
+drone-docker-runner
, I have a warehouse that will usedrone
to build adocker image
and upload it to theregistry
of my intranet, and builddrone
drone-docker-runner
and dind , also successfully accomplish the desired function - But then I found that there were a few more automatically generated
docker volume
on Synology. I thought it would be fine to delete it, but I found that I couldn’t delete it, and it prompted that I had no permission…
fool operation
User group lost
-
First of all, I thought the problem was caused by user groups such as
docker/containerd
. I didn’t want to delete the file system directly, so I didn’t confirm this. I preconceived that it was caused by the user group, and then called this command:sudo synogroup --member administrator docker
, but this is the beginning of the fool, because this command needs to pass in all the users that need to be placed in the group, here I wrote adocker
, which resulted in only thedocker
user
in theadministrator
group, and then I quitssh
and rebooted the system so I couldn’t log in from any angle… -
The solution was very
hack
, because I forwarded/var/run/docker.sock
throughsocat
, so I could operate Synology’sdocker
from other machines on the intranet, so I opened analpine
container and mounted/etc/group
to modify the user group, and finally restore…
(artificial) disk corruption
-
This is the beginning of the nightmare. In short, I tried all kinds of methods to delete the volume, but I unilaterally thought that the volume was no longer
ok
without knowingbtrfs
, so I decided to rebuild the storage space/storage pool and make this The decision is because my Synology does not have only one storage space, and the space where thedocker
is located is divided by the first hard disk (the characteristics of Synology, the first hard disk stores most of the system data and is used first) -
The nightmare is that I can’t delete the storage space/storage pool, unilaterally think that the file system is irreversibly damaged, so I make a more wrong decision, I want to cause artificial data damage, because only in this way can the system no longer hold files System related information, so I directly unplug the first hard drive and format it when it is turned on…
-
The next step is to delete the damaged storage space/storage pool, and rebuild the storage space/storage pool according to the process of adding a new hard disk; in fact, only the data of the package is affected, and it has no effect on my important data, because the storage space is divided separately. /storage pool to save…
Review
I will directly say the real reason after investigation here. Please study the hierarchical structure of
drone dind
by yourself.
-
Synology uses
btrfs
to implementstorage drive
withoverlayfs
docker
, so there is no choice -
According to the official documentation of
docker
, the image is actually abtrfs subvolume
locally, and all the upperlayer
aresnapshot
, so in my scenario, thedrone-docker-runner
anddocker:dind
images are in the host , which is Synology directbtrfs subvolume
on -
docker:dind
Dockerfile
VOLUME /var/lib/docker
so an anonymous volume will be generated in the host during operation, that is, the volume that I cannot delete. At this time, this volume is still a normal volume, behind which is thebtrfs
file system -
When the
pipeline
is running, it pulls other images by sharing/var/run/docker.sock
ofdocker:dind
. Of course, the location is in/var/lib/docker
ofdocker:dind
, which is the anonymous volume of the host, andbtrfs subvolume
is created.btrfs subvolume
-
After the build process is over,
drone-docker-runner
will be responsible for cleaning up temporary images and containers. For her, she only needs to perform the steps, and she doesn’t care whether it is really cleaned up. When theservice
ofdocker:dind
exits, it will not be actively cleaned up. The image that has been pulled (and there is no chance or reason to do this), so the final result is that an anonymous volume of the host contains abtrfs subvolume
-
Some people may wonder why they can’t delete it after clearing it. Here is another pit. According to the document: Arch WiKi – Btrfs , the
subvolume
ofbtrfs
needs to be deleted using thebtrfs
command, which can only be used in versions afterlinux 4.18
Ordinary file system commandsrm/rmdir
to delete, but coincidentally the current kernel version of Synology is only4.4.180+ (Linux Nazi 4.4.180+ #42661 SMP Fri Apr 1 15:31:10 CST 2022 x86_64 GNU/Linux synology_v1000_1621+)
, so it can’t be deleted… -
That is to say, what I can do with
btrfs subvolume list -p xxxx
and thenbtrfs subvolume delete yyyy
has gone around so much…
follow-up
-
Attempt to modify the build parameters and use other supported non-
btrfs
file systems to mount/var/lib/docker
, but the Synology kernel has limited support so it was unsuccessful -
Some people can see that because there is actually a way to delete it, it is a little troublesome, but this may be the obsessive-compulsive disorder of the programmer. I hope that each role can do what he should do, and don’t boast about his responsibilities and leave a tail. So in the end I decided to just level the hierarchy and let
docker:latest
map the host ‘s/var/run/docker.sock
to write the build myself. The philosophy of this matter is: either let the roles perform their duties, or leave them all The developer (aka myself) to fullyDIY
This article is reprinted from: https://www.dosk.win/2022/06/04/fu-pan-yi-ci-qun-hui-de-btrfs-docker-dind-yin-fa-de-zai-nan/
This site is for inclusion only, and the copyright belongs to the original author.