Hey
I run balena-engine on Debian distribution. I pull an image which have around 900 Mo. I remark on layer repository (balena-engine/vfs/dir) an excessive size of layer, around 5Go. There is only this image download on the board.
When I realize the pull operation with docker-engine, layers have around 900 Mo like the images. Why are there this difference ? And how reduce layer size ? 5Go is too much for our board.
How are you installing balena-engine in your distribution?
What version of Debian are you running?
Can you tell us what flags you are starting the daemon with?
What image are you pulling?
This should help us replicate what you’ve observed.
Also, in general for issues with balena-engine, it’s best to file a Github issue at https://github.com/balena-os/balena-engine/issues to get to the maintainers the quickest possible way! Just a future reference.
How are you installing balena-engine in your distribution?
i downloaded package with cmd : curl -sfL https://balena.io/engine/install.sh | sh and i followed this issue 55 to setting and start the service. https://github.com/balena-os/balena-engine/issues/55
What version of Debian are you running?
It is Debian 9 stretch
Can you tell us what flags you are starting the daemon with?
More over, I modified balena-engine.service to move balena-engine directory to a directory mounted on an usb key. My internal memory is limited to 8Go.
ExecStart=/usr/local/bin/balena-engine-daemon –data-root /mnt/usb/balena-engine-dir -H fd://
What image are you pulling?
It’s a private image base on this dockerfile :
Installed both Docker and balena-engine as you mentioned
I didn’t use an external USB, just the internal storage
It doesn’t look like it should be related to the base image, so I just pulled another image, that should be big, balenalib/amd64-node:12-build
When I’ve checked, both in the balenaEngine storage and the Docker storage it was the same, and that size that is suggested by the images output
Docker:
greg@debianengine:/var/lib/docker$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
balenalib/amd64-node 12-build eaa6b216aaa0 6 days ago 756MB
greg@debianengine:/var/lib/docker$ sudo du -h -d 1 |sort -h -r
789M .
786M ./overlay2
2.0M ./image
72K ./buildkit
52K ./network
28K ./volumes
20K ./plugins
20K ./builder
4.0K ./trust
4.0K ./tmp
4.0K ./swarm
4.0K ./runtimes
4.0K ./containers
balena-engine:
greg@debianengine:/mnt/balena$ sudo balena-engine images
REPOSITORY TAG IMAGE ID CREATED SIZE
balenalib/amd64-node 12-build eaa6b216aaa0 6 days ago 756MB
greg@debianengine:/mnt/balena$ sudo du -h -d 1 /mnt/balena |sort -h -r
789M /mnt/balena
786M /mnt/balena/overlay2
1.9M /mnt/balena/image
60K /mnt/balena/containerd
40K /mnt/balena/network
28K /mnt/balena/volumes
20K /mnt/balena/plugins
20K /mnt/balena/builder
4.0K /mnt/balena/trust
4.0K /mnt/balena/tmp
4.0K /mnt/balena/runtimes
4.0K /mnt/balena/containers
So at least with the overlay2 storage engine it doesn’t make a difference, and things work as they should.
Then I tried it out also with vfs storage driver (looked up the vfs docs for Docker as it seemed the actual suspect), pulling the same image, after setting the storage engine in both:
Docker with vfs:
greg@debianengine:/var/lib/docker$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
balenalib/amd64-node 12-build eaa6b216aaa0 6 days ago 756MB
greg@debianengine:/var/lib/docker$ sudo du -h -d 1 |sort -h -r
5.1G ./vfs
5.1G .
1.9M ./image
72K ./buildkit
40K ./network
28K ./volumes
20K ./plugins
20K ./builder
4.0K ./trust
4.0K ./tmp
4.0K ./swarm
4.0K ./runtimes
4.0K ./containers
Balena-engine with vfs:
greg@debianengine:/mnt/balena$ sudo balena-engine images
REPOSITORY TAG IMAGE ID CREATED SIZE
balenalib/amd64-node 12-build eaa6b216aaa0 6 days ago 756MB
greg@debianengine:/mnt/balena$ sudo du -h -d 1 /mnt/balena |sort -h -r
5.1G /mnt/balena/vfs
5.1G /mnt/balena
1.9M /mnt/balena/image
60K /mnt/balena/containerd
40K /mnt/balena/network
28K /mnt/balena/volumes
20K /mnt/balena/plugins
20K /mnt/balena/builder
4.0K /mnt/balena/trust
4.0K /mnt/balena/tmp
4.0K /mnt/balena/runtimes
4.0K /mnt/balena/containers
Thus the result is the same here, using docker or balena-engine is not the cause of the size difference but the ability of the storage engines.
Further questions:
are you using the same storage driver (both vfs) when you are comparing the size taken up?
what file system the external USB is formatted? It seems like vfs is forced when used on that? I would think if you format the external drive as ext4, then the overlay2 engine should be able to use space efficiently for you.
Thks for you feedback. Indeed docker and balena-engine use different storage driver (vfs for balena-engine and devicemapper for docker). External USB is formatted on ext4. I am going to search a way to change storage driver to fix my issue.
Unfortunately, I can’t change default storage driver with balena-engine. OverlayFS and aufs is not included on my distribution. Docker-engine use devicemapper like default storage driver. I would like to use the same driver for balena-engine but I have this error :
level=error msg=“Failed to GetDriver graph” driver=devicemapper error=“graphdriver plugins are only supported with experimental mode”
Docker root directory is stored on same place then balena-engine root directory. Based on docker article on devicemapper I changestorage driver for balena-engine by writing { “storage-driver”: “devicemapper” } on /etc/balena-engine/daemon.json.
Docker version :
docker info
Client:
Debug Mode: false
Server:
Server Version: 19.03.1
Storage Driver: devicemapper
Balena-engine version :
balena-engine info
Server Version: v17.12.0
Storage Driver: vfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Hi there! The error graphdriver plugins are only supported with experimental mode. indicates that you may put the daemon on experimental mode by setting "experimental": true on daemon.json docker configuration file for that, but it would be recommended to change default storage driver.
You can also add the --experimental flag to the engine startup line in your service (and the storage driver settings as well with --storage-driver, can see all the daemon flags with balena-engine-daemon --help).
What distribution/version are you using?
And out of curiosity, what makes you choose balenaEngine over docker for your use case?
Even with experimental flag to true, I can’t change storage driver. ( level=warning msg=“Unable to locate plugin: devicemapper”).
I use Debian 9 with custom kernel and OverlayFS module is not set. I am going to recompile kernel to have the recommend storage driver.
I work on custom board based on IMX6-DL and we wants to support balena tools on it. I try to setting balenaOS module on our DebianOS to communicate with BalenaCloud.
Apart from using a better overlay2 storage driver,
another thing I can suggest is to perhaps investigate is to find what is eating the storage space.
e.g. Check the following three commands. The sizes are quite consistent. You should be able to run the same for docker. Then compare outputs. Something strange is happening here and 4gb isn’t a small amount to eat up…
root@balena:~# du -hs /var/lib/balena/
208M /var/lib/balena/
root@balena:~# balena images
REPOSITORY TAG IMAGE ID CREATED SIZE
balenalib/intel-nuc-debian latest d825379dc3e1 7 days ago 162MB
balena/amd64-supervisor v10.0.3 49183b33301b 5 weeks ago 49.5MB
hello-world latest fce289e99eb9 7 months ago 1.84kB
root@balena:~# balena system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 3 1 211.9MB 162.4MB (76%)
Containers 1 0 84B 84B (100%)
Local Volumes 0 0 0B 0B
Build Cache 0 0 0B 0B
root@balena:~#