Skip to content

Conversation

@martenjacobs
Copy link

@martenjacobs martenjacobs commented Feb 25, 2022

This Dockerfile makes it easy to run fstransform under Docker.

docker build . -t fstransform

Usage is then simply:

docker run -it --privileged --rm fstransform [ARGS]

I tested it using the following:

docker run -it --rm --privileged -v "fstransform-work:/app/work" --entrypoint bash fstransform

Then from inside the docker container:

dd if=/dev/zero of=disk.img bs=1M count=100
losetup -fP disk.img
losetup -a
mkfs.xfs /dev/loop0
mkdir -p /mnt/loop
mount -t xfs /dev/loop0 /mnt/loop
dd if=/dev/zero of=/mnt/loop/file-1 bs=1M count=10
dd if=/dev/zero of=/mnt/loop/file-2 bs=1M count=20
dd if=/dev/zero of=/mnt/loop/file-3 bs=1M count=30
fstransform /dev/loop0 ext4

To clean up:

umount /mnt/loop
losetup -d /dev/loop0

@cosmos72
Copy link
Owner

cosmos72 commented Feb 26, 2022

I am not expert with docker - how do you access external devices/filesystems from inside it?

I am asking because if a docker installation of fstransform can only access devices/filesystems inside the docker container,
it would have limited usefulness in my opinion.

Maybe a user can merge the docker image of fstranform with other docker images, i.e. it's a way to install fstransform inside the docker image of any other software?

@martenjacobs
Copy link
Author

martenjacobs commented Feb 26, 2022

I am not expert with docker - how do you access external devices/filesystems from inside it?

I am asking because if a docker installation of fstransform can only access devices/filesystems inside the docker container, it would have limited usefulness in my opinion.

Maybe a user can merge the docker image of fstranform with other docker images, i.e. it's a way to install fstransform inside the docker image of any other software?

When using --privileged you can access all the device nodes from the main system (i.e. the loop device used in my example is actually a loop device on the Docker Desktop VM). So I can just use other devices, like /dev/sda1 from inside the container.

My example was just made to be nice and self-contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants