Community discussions

MikroTik App
 
Stuebi
just joined
Topic Author
Posts: 4
Joined: Mon Dec 11, 2023 1:50 pm

Mounted folder gets cleared when removing Container

Mon Dec 11, 2023 3:03 pm

Hi,

I am trying to use a container with mounted folder pointing to /usb1 on an hAP ax³ and i am having problems with data persistence. When storing files in the mounted folder, the files get deleted when the container is removed. Even if i download them via /fetch directly.

Setup
I download an custon image file via fetch command to /usb1/image.tar and add/extract it. Then download files to my mount folder. These files should be editable from the container, they should be kept even if i redeploy or delete the container. USB storage ist formatted using EXT4. Container is run under root so i can see files in mounted folders are also root owned.

Add mount and container and download custom config
/container/mounts/add name=data src=usb1/data dst=/data
/container/add file=usb1/image.tar interface=veth1 root-dir=usb1/container mounts=data workdir=/usr/src/node-red start-on-boot=yes logging=yes
/tool fetch url="https://www.mydomain.com/download/f/flows.json" mode=http dst-path=usb1/data/flows.json
Container has to be startet once, after it is stopped and removed, files i put in the /usb1/data path (for example downloaded flows.json file in above example) will also get removed. Is this a normal behaviour?
Is there any way how i can keep files created inside or outside of the container and reuse the mounted folder?

Tried to remove mount points from the container and remove the container in a second step also cleares the mount folder!?

Thank you very much for your support
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Mounted folder gets cleared when removing Container

Mon Dec 11, 2023 10:50 pm

I never had that issue and I'm using containers from first ROS version when introduced. Mounted directories and files in it always persist, no matter if are container store type (with .type file) or not.
Thing that interest me, fetch tool can write into container writable directory (container store)? Never tried, maybe this causes some bugs related to that. Is file from data directory removed if nothing from ROS is written by you? Try only write some file into that dir from container shell and stop and delete container when stopped - is it same behavior then?
I think it is not expected behavior from ROS shell that you can have r/w directory from ROS and container at same time, I guess that's why files from container store directories (writable in container) are not listed in /file and also to not overpopulate listing (for container root directories).
 
Stuebi
just joined
Topic Author
Posts: 4
Joined: Mon Dec 11, 2023 1:50 pm

Re: Mounted folder gets cleared when removing Container

Tue Dec 12, 2023 11:55 am

Hi,

i am using a different folder for data, not the container folder where the extracted image files are stored.
I do not access the extracted container folder (normally it is not accessible, but sometimes is, i think its also not normal behaiviour)

For now i changed the persistent folder from usb1 to local disk and the files do not get deleted when removing the container!?
I did not test this excessively, only gave it a few tries and files where persistent, no problems with deleted files...

I believe there is a bug with containers and touched files in mounted folders on usb drives.

Yes files created inside the container get also deleted from mount-folder when removing the container.
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Mounted folder gets cleared when removing Container

Tue Dec 12, 2023 3:33 pm

That's strange, I'm also using external usb drive for mounted directories and files never gets deleted on container removal.

Who is online

Users browsing this forum: No registered users and 5 guests