Go to the directory with the image you want to work with. Run a Docker container with that directory mounted:
docker run -it --privileged -v /dev:/dev -v (pwd):/tmp --workdir /tmp ubuntu bash
(replace (pwd)
with "$PWD"
if using bash instead of fish)
See this thread for an explanation of why --privileged
and -v /dev:/dev
are required. The need for the latter can be avoided with this alrternative workaround.
In the container, assuming that $IMAGE_FILE
is the name of your image file:
losetup -Pf --show $IMAGE_FILE
will output the name of the loop device with which the image is associated, e.g. /dev/loop0
.
ls /dev/loop0*
should show all the partitions contained in the image file.
You can mount these and access the files with e.g.
mkdir p1
mount /dev/loop0p1 p1
Note that the partition contents will only be accessible inside the Docker container, and not on the host (i.e. across Docker's volume map).
Thanks!
I would note that you can very easily copy everything to the host, by running this from the docker