LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 11-29-2023, 03:35 PM   #1
Micah
Member
 
Registered: Apr 2002
Location: OK, USA
Distribution: Slackware64
Posts: 190

Rep: Reputation: 37
Question Docker volume mount of .img file


I was looking for a simple way to archive a large set of small files and not letting size go crazy. If this works, I would just copy a single file as an archive vs spending hours sync'ing the files to a backup location.

From my research, my issue has something to do with the /dev/loop0 but from what I've seen they all say mount it first, then use it. Several try to create the loop in the container, but then you have to create the /dev entries. I'd rather leave that out of the container and let the host deal with it.

I'm trying to map a volume in my docker-compose.yaml, but it never appears in the container...

On the Host
Code:
truncate -s 5G /srv/myimage.img  
mkfs.btrfs /srv/myimage.img 
mount -o loop,discard,compress=lzo /srv/myimage.img /mnt/myimage/
The container (docker-compose snippet):
(I'm using version: '2' but I can use any version if needed.)
Code:
  app:
    build: dockerfolder
    container_name: myContainer
    network_mode: bridge
    restart: unless-stopped
    privileged: true
    device_cgroup_rules:
      - b 7:* rmw
    volumes:
      - /dev:/dev
      - /mnt/myimage:/data
I run this:
Code:
docker-compose exec app bash
df -h
but my volume doesn't appear. If I attempt to use it, it dumps the data to a folder on /mnt/myimage (of the host drive - you have to unmount the img to see it)

Last edited by Micah; 11-29-2023 at 04:42 PM. Reason: readability
 
  


Reply

Tags
docker



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Difference between docker.io, docker-cd, and Docker Desktop LXer Syndicated Linux News 0 08-15-2022 05:39 PM
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
[SOLVED] Mounting .img file (chromiumos.img); can't mount it?? Help please? linus72 Linux - General 2 11-27-2009 08:11 PM
[php]Reading url [img] and [/img] hylke Programming 13 08-23-2004 01:58 PM
.img burner or way to boot from a .img American Psycho Linux - Software 4 03-24-2004 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 02:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration