Execute commands inside containers from RouterOS scripts

Hi,

Idea. Be able to execute commands inside containers from RouterOS scripts/console. It could look like

:local result [/container exec 0 command="some_Linux_command --with arguments"]; :put $result

Use cases. Change config files and/or run additional binaries dynamically based on RouterOS events. Query container binaries, collect statuses. Debug containers without entering interactive console.

Existing workarounds. It’s possible to stop the container, change its entrypoint to run a custom command, start it again. It will execute the command and stop, then change its entrypoint back and start again. Finally, parse RouterOS logs to get the command output.

Such a workaround doesn’t fit if you would like to query the existing container processes (e.g. you have a ZeroTier container in CHR and would like to get a list of its peers with zerotier-cli).

Linux solution. See nsenter command.

What do you think about it?

Regards,

Surprised to see no comments from the community members. FYI, the support team says in SUP-154483 they “will consider it and may be will implement it in future”. If anyone is interested in this feature, please share your opinion here and/or create a new ticket to let MikroTik know.

Well, when I first tried to use containers in RouterOS, I was disappointed that I can’t run simple commands inside containers using scripts. Like, reloading nginx when SSL certificate was updated. I surely can restart it, but crictl/docker exec sounds easy enough not to miss this feature in RouterOS…