Chapter 09: Persistent data with UnionFS?
Hello everyone!
Is it possible to mount persistent volumes inside a conatiner using UnionFS? Let me explain what I'm training to archive here a little further:
Let's assume the following:
- On my host machine, I have a directory
/mnt/shareand a file calledfile_on_host.txtin that directory. - Furthermore, I have a container image that has a directory
/shareand a file calledfile_in_container.txtin that directory.
Now:
Is it possible to mount /mnt/share from my host machine inside a container under /share in such a way that both files are visible in the container? And that changes to either file are persistently stored in /mnt/share on my host machine. So when I start the container again, both files are "up to date"?
When I run:docker run --volume="/mnt/share:/share" -it my/image sh
I can only see the file file_on_host.txt in the container, but not file_in_container.txt.
In chapter 09 in section "Storage and Docker Volumes" it says:
Persistent volumes are not managed by UnionFS, ...
Is there a way to archive, what I want to do anyways?
Kind regards,
Andreas
Answers
-
Hi @schuam,
The UnionFS is a storage mechanism used to implement container image layers.
The mounting of volume, however, in a container at runtime follows the expected mounting behavior, where the source overwrites (temporarily for the duration of the mount) the destination. That is the reason you only see the host file after the mount, but not the container file. Running the container without a mount would reveal the container file.
A solution, which I have not tried, to install unionfs-fuse tool in the container, and create a union directory between a container directory and a mounted directory, in a similar way as explored by the lab exercise. A direct mount, however, would just overwrite the container file with the host file.
Regards,
-Chris0 -
Hi @chrispokorni,
thank you very much for your answer and the hint to the unionfs-fuse that was use in one of the labs. I haven't gotten to try it out, but I will as soon as I find the time to do so.
Best regards,
Andreas0
Categories
- All Categories
- 177 LFX Mentorship
- 177 LFX Mentorship: Linux Kernel
- 755 Linux Foundation IT Professional Programs
- 375 Cloud Engineer IT Professional Program
- 170 Advanced Cloud Engineer IT Professional Program
- 74 DevOps IT Professional Program - Discontinued
- 5 DevOps & GitOps IT Professional Program
- 100 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 2 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 5 Cloud & Containers Training
- 1 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 1 Networking Training
- 2 Open Source Best Practice Training
- 2 System Administration Training
- 1 System Engineering Training
- 1 Web & Application Development Training
- 795 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 90 Storage
- 769 Linux Distributions
- 81 Debian
- 68 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 112 Mobile Computing
- 20 Android
- 77 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 393 Off Topic
- 121 Introductions
- 182 Small Talk
- 29 Study Material
- 980 Programming and Development
- 310 Kernel Development
- 652 Software Development
- 995 Software
- 387 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)