EvilFreelancer / docker-routeros

Mikrotik RouterOS inside Docker container
https://hub.docker.com/r/evilfreelancer/docker-routeros/
MIT License
356 stars 127 forks source link

This vs. VM #12

Closed mhkarimi1383 closed 7 months ago

mhkarimi1383 commented 3 years ago

I want to see this image is more efficient or Virtual machine Because you are using qemu inside alphine

EvilFreelancer commented 3 years ago

Hello! Unfortunately it is not simple extract RouterOS and pack to Docker image directly (without virtual machine level), I've tried many different ways, and qemu based solution was the most optimal for achieving the goal. But a lot of time has passed since then, perhaps more convenient tools have appeared for solving such problems. Maybe you can suggest more optimal solution?

mhkarimi1383 commented 3 years ago

I think If you have microtik you can just get it's rootfs (like other OSes) and put it in a tarball and using ADD in docker you can extract it into / and just use CMD ["/bin/sh"] like here for alphine https://github.com/alpinelinux/docker-alpine/tree/v3.13/x86_64

EvilFreelancer commented 3 years ago

Yes, it is possible, but problem is that it won't work and when you try to run such a Docker image, you will get a kernel panic of your host machine. By the way, you don't need to have a router at hand, just unpack the operating system from archive image or VM image.

mhkarimi1383 commented 3 years ago

let me try it out :)

mhkarimi1383 commented 3 years ago

I did it but I got this error

ERROR: opening root device = Operation not permitted
ERROR: opening root device = Operation not permitted
ERROR: opening root device = Operation not permitted
ERROR: opening root device = Operation not permitted
ERROR: opening root device = Operation not permitted
ERROR: opening root device = Operation not permitted
ERROR: opening boot device = Operation not permitted
ioctl FIBMAP failed
ioctl FIBMAP failed
ioctl FIBMAP failed
ioctl FIBMAP failed
ioctl FIBMAP failed
ioctl FIBMAP failed

Here is my Dockerfile

FROM scratch
ADD . /
CMD ["/bin/milo"]
EvilFreelancer commented 3 years ago

Yep, because RouterOS is not just a shell, it also a custom linux kernel with tons of patches related to Miktorik devices.

EvilFreelancer commented 3 years ago

This is why i've choose the qemu based solution.

mhkarimi1383 commented 3 years ago

It will be better if we know what to run to make it working