v7.1rc3 adds container support

Hey folks,

I recently upgraded 1100 AHx4 to 7.1.rc4 in order to test containers.
Although I manage to make it work. I faced the below issues:

  • Transferring big files is causing kernel panic
  • Extracting tar image takes more than 15mins which consumes 1 CPU and cause packet drop and Capsman link drop
  • There is no exec to get a console in order to configure more.

Have you found any solution for the above?

Thanks,
Nikos

No problem with file transfers in ny case. I use ‘scp’ and webfig for uploading (RB4011, ARMv7 32 bit).

Regarding the lack of interactive console shell, you have to settle for images with ssh, web config or environment variables. This is really annoying. I hope we get interactive shell soon. My kingdom for ‘docker exec -it bash‘

First I was using openwrt images (mips_24kc-21.02.0 tag on https://hub.docker.com/r/openwrtorg/rootfs) . However, I suspect something about their init system is causing the 100% cpu usage. Now I’m rolling my own images based on openwrt but without their init system.


I have just been making tarballs of the root fs and then using

docker import

and

docker export

to add the necessary metadata


There won’t be. Since mipsbe isn’t officially supported by docker, it wont let you tag an image as being for it (see https://github.com/docker/cli/blob/a32cd16160f1b41c1c4ae7bee4dac929d1484e59/cli/command/manifest/util.go#L22) . However other than displaying it in the UI, ROS seems to ignore the platform tag (my images all say AMD64, but they are running fine)


adding logging=yes seems to just log stdout/stderr from inside the container, no info about debugging the container runtime itself. There is some limited debugging info available in supout.rif in the

@container@

sections

How are you reading supout.rif? I viewed my supout.rif in mikrotik.com → account but It doesn’t contain a “container” section :frowning:

EDIT: Thank you so much, finally a bit of hint of logging. I used a third party tool (github.com/farseeker/go-mikrotik-rif) to open the supout and found this.

@container@
2021.09.20-21:07:21.81@1: Starting container app.
2021.09.20-21:07:21.81@1: Running app...
2021.09.20-21:14:08.29@3: unable to copy resolv.conf
2021.09.20-21:14:08.30@3: clone: Invalid argument
2021.09.20-21:14:08.30@3: child spawn failed
2021.09.20-21:14:19.53@2: unable to copy resolv.conf
2021.09.20-21:14:19.53@2: clone: Invalid argument
2021.09.20-21:14:19.53@2: child spawn failed
2021.09.20-21:14:20.92@2: image not running
2021.09.20-21:25:41.33@1: no id
2021.09.20-21:40:04.07@3: clone: Invalid argument
2021.09.20-21:40:04.07@3: child spawn failed
2021.09.20-21:40:45.10@0: clone: Invalid argument
2021.09.20-21:40:45.10@0: child spawn failed
2021.09.20-21:41:12.92@2: clone: Invalid argument
2021.09.20-21:41:12.92@2: child spawn failed
2021.09.21-18:55:23.41@0: clone: Invalid argument
2021.09.21-18:55:23.41@0: child spawn failed
2021.09.21-18:55:45.42@1: clone: Invalid argument
2021.09.21-18:55:45.42@1: child spawn failed
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: /ram/pckg/container/nova/bin/container
2021.09.21-18:57:16.72@1: --- signal=17 --------------------------------------------
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: pc=0x77fe4214 at=0x00000001 v0=0x00000004 v1=0x00000000
2021.09.21-18:57:16.72@1: a0=0x77ff9560 a1=0x00000002 a2=0xffffffff a3=0x00000001
2021.09.21-18:57:16.72@1: t0=0x00000001 t1=0x77f7aa90 t2=0x66206e77 t3=0x656c6961
2021.09.21-18:57:16.72@1: t4=0x7fffb780 t5=0x00000000 t6=0x00000000 t7=0x00420000
2021.09.21-18:57:16.72@1: s0=0x0000105c s1=0xffffffff s2=0x780014f4 s3=0x7fffbbc0
2021.09.21-18:57:16.72@1: s4=0x0000004f s5=0xffffffff s6=0x00000004 s7=0x00421558
2021.09.21-18:57:16.72@1: t8=0x004209a0 t9=0x77fe41d0 k0=0x00000000 k9=0x00000000
2021.09.21-18:57:16.72@1: gp=0x780018d0 sp=0x7fffbac8 s8=0x004217f8 ra=0x77fdc120
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: maps:
2021.09.21-18:57:16.72@1: 00400000-00411000 r-xp 00000000 07:01 8          /ram/pckg/container/nova/bin/container
2021.09.21-18:57:16.72@1: 00420000-00421000 rwxp 00010000 07:01 8          /ram/pckg/container/nova/bin/container
2021.09.21-18:57:16.72@1: 00421000-0042c000 rwxp 00000000 00:00 0          [heap]
2021.09.21-18:57:16.72@1: 77de5000-77ee5000 rwxp 00000000 00:00 0 
2021.09.21-18:57:16.72@1: 77ee5000-77f07000 r-xp 00000000 07:00 241        /lib/libuc++.so
2021.09.21-18:57:16.72@1: 77f07000-77f08000 rwxp 00012000 07:00 241        /lib/libuc++.so
2021.09.21-18:57:16.72@1: 77f08000-77f77000 r-xp 00000000 07:00 243        /lib/libumsg.so
2021.09.21-18:57:16.72@1: 77f77000-77f79000 rwxp 0005f000 07:00 243        /lib/libumsg.so
2021.09.21-18:57:16.72@1: 77f79000-77f7b000 rwxp 00000000 00:00 0 
2021.09.21-18:57:16.72@1: 77f7b000-77fa4000 r-xp 00000000 07:00 247        /lib/libubox.so
2021.09.21-18:57:16.72@1: 77fa4000-77fa5000 rwxp 00019000 07:00 247        /lib/libubox.so
2021.09.21-18:57:16.72@1: 77fa5000-77fea000 r-xp 00000000 07:00 240        /lib/libc.so
2021.09.21-18:57:16.72@1: 77ff6000-77ff7000 rwxs 00000000 00:0a 2052       /ram/rtrace/control
2021.09.21-18:57:16.72@1: 77ff7000-77ff9000 r-xp 0ea7c000 00:06 1326       /dev/jiffies
2021.09.21-18:57:16.72@1: 77ff9000-77ffb000 rwxp 00044000 07:00 240        /lib/libc.so
2021.09.21-18:57:16.72@1: 77ffb000-77ffc000 rwxp 00000000 00:00 0 
2021.09.21-18:57:16.72@1: 7ffdb000-7fffc000 rwxp 00000000 00:00 0          [stack]
2021.09.21-18:57:16.72@1: 7fffc000-7fffd000 r-xp 00000000 00:00 0 
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: stack: 0x7fffc000 - 0x7fffbac8 
2021.09.21-18:57:16.72@1: 00 00 00 00 40 11 42 00 d0 f8 f7 77 58 15 42 00 00 00 00 00 00 00 00 00 d0 18 00 78 5c 10 00 00 
2021.09.21-18:57:16.72@1: 00 00 00 00 00 00 00 00 10 10 42 00 30 bb ff 7f ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: code: 0x77fe4214
2021.09.21-18:57:16.72@1: 10e00002 27bd0020 00021023 03e00008 00000000 8f998574 03200008 00000000 
2021.09.21-18:57:16.72@1: 
2021.09.21-18:57:16.72@1: backtrace: 0x77fe4214 0x77fdc120 
2021.09.21-18:57:16.72@1:

Any idea anyone?

What version are you running. I was seeing the same error on rc3 as the kernel was not built with full support for namespaces. Issue was resolved with rc4

7.1rc4. Then guess it wasn’t solved for mmpis/RB750Gr3

Hello! Tried pihole and iperf on my ac3 with external usb flash. Both stuck on “extracting”. Any ideas?

thanks for the hint! looking at supout.rif with the tool go-mikrotik-rif i get similar stack trace:

@container@
2021.10.05-00:18:06.50@0: 
2021.10.05-00:18:06.50@0: 
2021.10.05-00:18:06.50@0: /ram/pckg/container/nova/bin/container
2021.10.05-00:18:06.50@0: --- signal=17 --------------------------------------------
2021.10.05-00:18:06.50@0: 
2021.10.05-00:18:06.50@0: pc=0x77fd4654 at=0x00000001 v0=0x00000004 v1=0x00000000
2021.10.05-00:18:06.51@0: a0=0x77f0ef00 a1=0x00000002 a2=0xffffffff a3=0x00000001
2021.10.05-00:18:06.51@0: t0=0x00000000 t1=0xfeffffff t2=0x00421064 t3=0x77f82fb0
2021.10.05-00:18:06.51@0: t4=0x00000001 t5=0x10000000 t6=0x77f82980 t7=0x77f20000
2021.10.05-00:18:06.51@0: s0=0x00421064 s1=0xffffffff s2=0x77f80000 s3=0x7fffabe0
2021.10.05-00:18:06.51@0: s4=0x0000004f s5=0xffffffff s6=0x00000004 s7=0x00421558
2021.10.05-00:18:06.51@0: t8=0x004208dc t9=0x77fd4640 k0=0x77f7f960 k9=0x00000000
2021.10.05-00:18:06.51@0: gp=0x78001370 sp=0x7fffab70 s8=0x004217f8 ra=0x77f33848
2021.10.05-00:18:06.51@0: 
2021.10.05-00:18:06.51@0: maps:
2021.10.05-00:18:06.51@0: 00400000-00411000 r-xp 00000000 07:01 8          /ram/pckg/container/nova/bin/container
2021.10.05-00:18:06.51@0: 00420000-00421000 rwxp 00010000 07:01 8          /ram/pckg/container/nova/bin/container
2021.10.05-00:18:06.51@0: 00421000-0042d000 rwxp 00000000 00:00 0          [heap]
2021.10.05-00:18:06.51@0: 77dec000-77eec000 rwxp 00000000 00:00 0 
2021.10.05-00:18:06.51@0: 77eec000-77f0e000 r-xp 00000000 07:00 240        /lib/libuc++.so
2021.10.05-00:18:06.51@0: 77f0e000-77f0f000 rwxp 00012000 07:00 240        /lib/libuc++.so
2021.10.05-00:18:06.51@0: 77f10000-77f7f000 r-xp 00000000 07:00 242        /lib/libumsg.so
2021.10.05-00:18:06.52@0: 77f7f000-77f81000 rwxp 0005f000 07:00 242        /lib/libumsg.so
2021.10.05-00:18:06.52@0: 77f81000-77f83000 rwxp 00000000 00:00 0 
2021.10.05-00:18:06.52@0: 77f84000-77fad000 r-xp 00000000 07:00 246        /lib/libubox.so
2021.10.05-00:18:06.52@0: 77fad000-77fae000 rwxp 00019000 07:00 246        /lib/libubox.so
2021.10.05-00:18:06.52@0: 77fae000-77fea000 r-xp 00000000 07:00 239        /lib/libc.so
2021.10.05-00:18:06.52@0: 77ff4000-77ff5000 rwxs 00000000 00:0a 370        /ram/rtrace/control
2021.10.05-00:18:06.52@0: 77ff6000-77ff8000 r-xp 0717c000 00:06 393        /dev/jiffies
2021.10.05-00:18:06.52@0: 77ff9000-77ffa000 rwxp 0003b000 07:00 239        /lib/libc.so
2021.10.05-00:18:06.52@0: 77ffa000-77ffb000 rwxp 00000000 00:00 0 
2021.10.05-00:18:06.52@0: 7ffda000-7fffb000 rwxp 00000000 00:00 0          [stack]
2021.10.05-00:18:06.52@0: 7fffb000-7fffc000 r-xp 00000000 00:00 0 
2021.10.05-00:18:06.52@0: 
2021.10.05-00:18:06.52@0: stack: 0x7fffb000 - 0x7fffab70 
2021.10.05-00:18:06.52@0: 77 f7 f9 60 00 00 00 00 7f ff ab a0 00 ff 00 00 77 f8 79 f0 77 f3 f6 0c 00 42 10 64 00 42 11 14 
2021.10.05-00:18:06.53@0: 7f ff ac 80 7f ff ab e0 00 00 00 4f ff ff ff ff 00 00 00 04 77 f3 3a a0 77 f8 2b 00 77 fc 0e a8 
2021.10.05-00:18:06.53@0: 
2021.10.05-00:18:06.53@0: code: 0x77fd4654
2021.10.05-00:18:06.53@0: 10e00002 00402025 00022023 8f998078 100099ea 00000000 00000000 3c1c0003 
2021.10.05-00:18:06.53@0: 
2021.10.05-00:18:06.53@0: backtrace: 0x77fd4654

from what i experimented so far with building a container from scratch, and trying to run it on an rb960pg (mipsbe) i can tell:

  • if it stucks at status extracting, there is something wrong with the container image (tar file)
  • if it does not start but extracts fine, container image seems ok but there is something wrong with the binaries within the container or the container was built/saved on wrong architecture.
  • comparing architectures, with a container built on mips64 or mipsel i get stacktrace with signal 11 (SIGSEGV - Segmentation violation)
  • saving the built container from a mips32 system i get signal 17 (SIGUSR2 - User-defined signal 2) stacktrace.

so not only the architecture has to match (what is clear to me), but also the build-tools have to match i guess?
i am trying to build the container on a qemu-mips (malta) VM running openwrt 21.02, which uses musl toolchain afaik.
the binaries which run fine in openwrt on mips32 seem not to work in the container on the rb960.
does anybody know what toolchain must be used for binaries in a container to run on a rb960pg (mipsbe) ?

What’s old is new again. Mikrotik was ahead of it’s time with MetaROUTER. And, yet still people wanting to run a full Linux distro with stuff PBX etc. But with MetaROUTER, the Wiki had a clear description of how to use with ROS – that’s missing in v7 Containers IMO.

Just saying ROS-on-ROS is could be simplier for stuff like VRF, and likely good example of “SDN” potential of Containers. Since there are no examples of any containers for TILE, if Mikrotik had some examples of getting ROS in a working container, that be a good place to know if anyother container could on some hardware platform.

Tried to create .tar in Linux invironment (instead of windows 10) and everything works!

sorry, i overlooked that comment.
many many thanks for that information! based on that i also could finally get a container to work. based on that container i built my own container.

i tried that but maybe i did something wrong because this didnt work for me, but based on the mips_24kc-21.02.0 openwrt container i could create a container myself and build it with “docker build -t mytag .” then “docker save mytag > mytag.tar” to use the tar file on the router.

so i got a working container on a rb960pgs which is really nice!

just giving feedback:
following things i noticed are not (yet) working correctly, but i guess they will be fixed in future ROS versions:

  • “sometimes” after stopping a container the file autosupout.rif is written and then starting a container is not possible any more until the router is rebootet. (in autosupout.rif i see signal 11 in the log)
  • when the container is running, after a usual reboot of the router, the container store and the tar-file/image is lost, but the configuration is still there, so i have to remove the container, upload the image and add it again.
  • are containers started automatically after router reboot? (assuming the previous mentioned problem is fixed)
  • “sometimes” i have to “/container/start number=0” more than once until the container starts correctly although nothing changed and i just uploaded the image again and re-added the container. looking in supout.rif i see signal 17 as described before.

thanks for this great feature, keep it up!

Is it possible to get access to devices connected to the USB Bus from within Docker?
(=run Docker in piviledged mode?)
If yes, could you please post an example?

So I could interact with USB devices (IE Serial devices) from within Docker?

Thanks
Janosch

No, because entire point of having docker is to isolate it from rest of the ROS environment.
Maybe sharing USB block devices with docker container can be added as a feature later…

But for now you can use following workaround:
Set up serial port server(s) in ROS and then you can access your USB serial ports over TCP/IP, ie. even from the container.
As long as it’s just serial port (and not some other device that would require libusb access) it should work without problems.

I would like it if containers didn’t have to be placed behind NAT…

Please Mikrotik, at least add the ability to use host networking. others would be potentially useful but limiting us to only bridge networking limits what can be done inside a container running on a mikrotik device. https://docs.docker.com/network/#network-drivers

Avahi (mdns Reflector)

Hap AC^2 (256M)

It took a while to get working, but I was able to build an Avahi container. Using the cross build instructions at

https://hub.docker.com/r/taoyou/iperf3-alpine

And the avahi container at

https://github.com/flungo-docker/avahi

It came out a bit over 8M in size, so quite big.

It uses a couple of vlans (Vlan setup currently hard coded in the tar file) on it’s veth to connect to the local networks.

It is configured as a mdns reflector.

While working out how to make it work, I used netcat from openwrt to provide a couple of cli sessions. The cli is very basic but works, (You need 2 for when you break one) Probably should learn how to setup a dropbear.

I used 7zip on my desktop to open the tar file, and edit config files, and insert the executables (netcat binary and runcat2.sh script)

It seems to work ok.
Not sure I really want it now though :frowning:

Hey,
tried to run pi-hole on CHR getting this

 (445): Fatal Error Unable to allocate shared memory segment of 134217728 bytes: shmget: Function not implemented (38)

[api@RouterOS] > container envs/pri
 0 list="pihole" name="TZ" value="Asia/Kolkata" 

 1 list="pihole" name="Server IP" value="172.16.10.2" 

 2 list="pihole" name="WEBPASSWORD" value="password" 
[api@RouterOS] > container/print 
 0 file=pihole.tar name="471a7373-e48f-480b-aca2-7c7ee7195241" 
   tag="pihole/pihole:latest" os="linux" arch="amd64" interface=veth1 
   envlist="pihole" mounts="" dns="" hostname="PiHole" logging=yes 
   status=stopped 
[api@RouterOS] > 
[api@RouterOS] > system resource prin
                   uptime: 2m41s
                  version: 7.1rc4 (testing)
               build-time: Sep/20/2021 10:18:44
              free-memory: 14.1MiB
             total-memory: 96.0MiB
                      cpu: Intel(R)
                cpu-count: 1
            cpu-frequency: 2599MHz
                 cpu-load: 1%
           free-hdd-space: 1416.3MiB
          total-hdd-space: 2038.1MiB
  write-sect-since-reboot: 1320
         write-sect-total: 1321
        architecture-name: x86_64
               board-name: CHR
                 platform: MikroTik

Any idea what could be the problem?

This is the complete log that comes:

Oct/18/2021 09:14:06 container,info,debug [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
Oct/18/2021 09:14:07 container,info,debug [s6-init] ensuring user provided files have correct perms...exited 0.
Oct/18/2021 09:14:07 container,info,debug [fix-attrs.d] applying ownership & permissions fixes...
Oct/18/2021 09:14:07 container,info,debug [fix-attrs.d] 01-resolver-resolv: applying... 
Oct/18/2021 09:14:07 container,info,debug [fix-attrs.d] 01-resolver-resolv: exited 0.
Oct/18/2021 09:14:07 container,info,debug [fix-attrs.d] done.
Oct/18/2021 09:14:07 container,info,debug [cont-init.d] executing container initialization scripts...
Oct/18/2021 09:14:07 container,info,debug [cont-init.d] 20-start.sh: executing... 
Oct/18/2021 09:14:08 container,info,debug  ::: Starting docker specific checks & setup for docker pihole/pihole
Oct/18/2021 09:14:09 container,info,debug 
Oct/18/2021 09:14:09 container,info,debug   [i] Installing configs from /etc/.pihole...
Oct/18/2021 09:14:09 container,info,debug   [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
Oct/18/2021 09:14:09 container,info,debug   [i] Installing /etc/dnsmasq.d/01-pihole.conf...
[K  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
Oct/18/2021 09:14:09 container,info,debug   [i] Installing /etc/.pihole/advanced/06-rfc6761.conf...
[K  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
Oct/18/2021 09:14:14 container,info,debug Existing DNS servers detected in setupVars.conf. Leaving them alone
Oct/18/2021 09:14:14 container,info,debug ::: Pre existing WEBPASSWORD found
Oct/18/2021 09:14:14 container,info,debug DNSMasq binding to default interface: eth0
Oct/18/2021 09:14:14 container,info,debug Added ENV to php:
Oct/18/2021 09:14:14 container,info,debug 			"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log",
Oct/18/2021 09:14:14 container,info,debug 			"ServerIP" => "0.0.0.0",
Oct/18/2021 09:14:14 container,info,debug 			"CORS_HOSTS" => "",
Oct/18/2021 09:14:14 container,info,debug 			"VIRTUAL_HOST" => "0.0.0.0",
Oct/18/2021 09:14:14 container,info,debug Using IPv4 and IPv6
Oct/18/2021 09:14:14 container,info,debug ::: Preexisting ad list /etc/pihole/adlists.list detected ((exiting setup_blocklists early))
Oct/18/2021 09:14:14 container,info,debug https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
Oct/18/2021 09:14:15 container,info,debug ::: Testing pihole-FTL DNS: FTL started!
Oct/18/2021 09:14:18 container,info,debug ::: Testing lighttpd config: Syntax OK
Oct/18/2021 09:14:18 container,info,debug ::: All config checks passed, cleared for startup ...
Oct/18/2021 09:14:18 container,info,debug ::: Enabling Query Logging
Oct/18/2021 09:14:19 container,info,debug   [i] Enabling logging...
Oct/18/2021 09:14:19 container,info,debug 
[K  [✓] Logging has been enabled!
Oct/18/2021 09:14:19 container,info,debug  ::: Docker start setup complete
Oct/18/2021 09:14:19 container,info,debug   Checking if custom gravity.db is set in /etc/pihole/pihole-FTL.conf
Oct/18/2021 09:14:19 container,info,debug   Pi-hole version is v5.5 (Latest: v5.5)
Oct/18/2021 09:14:19 container,info,debug   AdminLTE version is v5.7 (Latest: v5.7)
Oct/18/2021 09:14:20 container,info,debug   Current FTL version is v5.10.2
Oct/18/2021 09:14:20 container,info,debug   Container tag is: 2021.10
Oct/18/2021 09:14:20 container,info,debug [cont-init.d] 20-start.sh: exited 0.
Oct/18/2021 09:14:20 container,info,debug [cont-init.d] done.
Oct/18/2021 09:14:20 container,info,debug [services.d] starting services
Oct/18/2021 09:14:20 container,info,debug [services.d] done.
Oct/18/2021 09:14:20 container,info,debug Starting pihole-FTL (no-daemon) as root
Oct/18/2021 09:14:20 container,info,debug Starting lighttpd
Oct/18/2021 09:14:20 container,info,debug Starting crond
Oct/18/2021 09:14:29 container,info,debug Mon Oct 18 03:44:29 2021 (423): Fatal Error Unable to allocate shared memory segment of 134217728 bytes: shmget: Function not implemented (38)
Oct/18/2021 09:14:34 container,info,debug Mon Oct 18 03:44:34 2021 (424): Fatal Error Unable to allocate shared memory segment of 134217728 bytes: shmget: Function not implemented (38)
Oct/18/2021 09:14:38 container,info,debug Mon Oct 18 03:44:38 2021 (425): Fatal Error Unable to allocate shared memory segment of 134217728 bytes: shmget: Function not implemented (38)

after this CHR becomes unresponsive and reboots with a ‘kernel panic’

having memory, there is portainer.io, should be installed as a normal docker image, and provides a simple graphical interface to install all the images you want. you can customize the run commands, extensions, ports, volumes, etc..

is it on purpose, that there is no container package for SMIPS architecture or was it just forgotten?
on all architectures i can find the container package in the all_packages-*-7.1rc4.zip file but not for SMIPS ?

There is no SMIPS device with enough RAM to allow the use of Docker containers…