Fixe the race condition between docker run and docker logs from #428

Wait for the container to terminate at the end of CmdRun.