lundi 29 novembre 2021

cmd: Open a browser when a string is output using docker

I'm running a docker command from inside cmd (a .bat script). The command looks like docker run --shm-size=1gb -it --privileged --name test p 8080:8080 -h test thom/test:latest I want to make a loop that waits for a certain string to appear after I invoke this command, or it waits for the port (8080) to be open. The string is "Daemon started!", and when it is output, I want to open a browser:

explorer "http://localhost:8080"

I'm struggling to make a while loop in batch though without restarting the docker command. This is what I have so far.

:loop
timeout /t 5
(docker run --shm-size=1gb -it --privileged --name test p 8080:8080 -h test thom/test:latest | find "proxy Daemon started!")  > nul 2>&1
if find "proxy Daemon started!" goto loop
echo I can go!
explorer "http://localhost:8080

 

Aucun commentaire:

Enregistrer un commentaire