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
- 178 LFX Mentorship
- 178 LFX Mentorship: Linux Kernel
- 774 Linux Foundation IT Professional Programs
- 383 Cloud Engineer IT Professional Program
- 175 Advanced Cloud Engineer IT Professional Program
- 75 DevOps IT Professional Program - Discontinued
- 7 DevOps & GitOps IT Professional Program
- 103 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 12 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 32 Cloud & Containers Training
- 3 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 2 Networking Training
- 2 Open Source Best Practice Training
- 5 System Administration Training
- 1 System Engineering Training
- 6 Web & Application Development Training
- 798 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 92 Storage
- 772 Linux Distributions
- 81 Debian
- 68 Fedora
- 24 Linux Mint
- 13 Mageia
- 24 openSUSE
- 151 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 469 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 101 Linux Security
- 79 Network Management
- 101 System Management
- 46 Web Management
- 165 Mobile Computing
- 32 Android
- 118 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 406 Off Topic
- 128 Introductions
- 34 Study Material
- 1K Programming and Development
- 310 Kernel Development
- 720 Software Development
- 1K Software
- 418 Applications
- 182 Command Line
- 5 Compiling/Installing
- 71 Games
- 320 Installation
- Archived
- 183 Small Talk
- 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)