I’m trying to create an script to delete the current Container image and download a new one, but the command /container remove numbers=0 don’t work (this proccess is after the command /container/stop number=0 and delay 15s).
Executing /container remove number=0 via MikroTik terminal, works without problem… I haved tryed only the command /container remove number=0 in script (to see if it will work only with this process) and no good, so the problem is with this command and now I’m thinking:
It’s a problem with scripts on version 7.6?
It’s because the image is in USB drive (but via terminal the process works…)?
User problem (it’s admin), or it’s because DNSMASQ_USER is seted with root user?
P.S: All process described here were made with Winbox and RouterOS version 7.6
Thank you so much, works like a charm.
With “find + tag” ([find tag=“pihole/pihole:latest”]) seen’s more objective (even for me running only one container).
Thanks again.
To get more complex, you can wait for the container to stop. Since the remove will fail if the container is not stopped, but the “stop” just requests the container to shutdown. It may not do so right aways, so the remove can fail. Also use a variable to store the “tag” you want to use, and a “~” which mean regex (or partial string matching, so just “pihole” will match on “pihole:latest” or any “sub-tag”) for an even better example in case it wasn’t “pihole” you want to do this with.
e.g. the :do waits for the stop, which be important if you want to do this as part of a larger script. Interactively at Terminal, you can just retry the remove if it fails.
I normally wrapped things in functions. A function avoids needing a global and cut-and-paste - especially if you need to do it multiple times/interactively:
The “function” above does nothing – just just defines a new command-like thing to call to remove a container by tag. So if that add at top of script (or via scheduler at startup), you can then just use:
Great!
I have put an daley (300s) to wait the stop command, but with this possibilities you told, I’ll try other ways and with that, refine the script. Thanks a lot for your time and good will.