【发布时间】:2016-11-01 21:04:51
【问题描述】:
对于一个项目,我需要在运行 ubuntu 的 docker 容器中安装一个 linux 映像。我要挂载的图像是 Raspbian。我需要访问镜像的linux文件系统并添加一个文件。
我通过挂载带有卷标志的文件夹来访问图像:
docker run -it -v /path/to/image/folder:/default ubuntu /bin/bash
使用fdisk -l raspbian.img 我找到了偏移量:
Disk raspbian.img: 1.3 GiB, 1389363200 bytes, 2713600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5a7089a1
Device Boot Start End Sectors Size Id Type
raspbian.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
raspbian.img2 137216 2713599 2576384 1.2G 83 Linux
现在,当我尝试使用mount -o loop,offset=$((137216*512)) raspbian.img /mnt/ 挂载映像时,我得到mount: /mnt/: mount failed: Unknown error -1。有人可以解释一下我是否可以在正在运行的 docker 容器中挂载一个 linux 映像,如果可以的话怎么办?
编辑
在 vagrant 中执行相同的挂载操作非常有效。 docker 挂载文件系统有一些限制吗?
【问题讨论】:
-
Raspbian 旨在在裸机 ARM 硬件下运行,而不是在 VM 内。此外,它需要 ARM,您可能已经在其他平台下设置了 docker/ubuntu 对吧?
-
我知道。但我想挂载图像的文件系统。我不想启动 raspbian。