Problem with a Script for Containers

I wanted to automate a container start and container shell command in mirkotik scripting. I want to scan the hostname and status of the container. I wrote a code wich should work but it doesn t and I don t know why. i first tried just looking at the hostname but it doesn t work either. the if statement just doesn t run and i get no log output.

:local myName do={:put "hostname";:return};
:local myCon do={:put "container";:return};
:local userinput [$myName];
:local containerlist [$myCon];
:local var1 [/container find count-only where hostname=$userinput]];
:if ( $var1 = "0") do ={ 
/container start $containerlist;
/container shell $containerlist;
:log info "is  running";
} else {
:log info "doesn't work";
}

I want to post this because maybe someone could need it.
I found a much better script wich is very simple and working good.

:local myCon do={:put "container"; :return};
:local containerlist [$myCon];
:put "Docker is running";
/container start $containerlist;
/container shell $containerlist;
delay 1;
/container stop $containerlist;

It will stop the container the moment you exit the shell.
This is needed because there is a bug in the Terminal in the version I am using (RouterOS v7.6rc1) if u run a container wich is already running. With stopping it while exiting the shell, there is never a posibility to get that bug.