Article 6GRT8 Docker volume mount of .img file

Docker volume mount of .img file

by
Micah
from LinuxQuestions.org on (#6GRT8)
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:/dataI run this:
Code:docker-compose exec app bash
df -hbut 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)
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments