Storing last line of Docker log tail to a shell variable

I am trying to achieve a rather simple task, however I have been failing at it for quite a few hours now. I am sure I am missing something simple.

All I am trying to do is to capture the last line of docker log to a variable in a shell script.

Here is my setup:

Dockerfile:

FROM python:3.7.2
WORKDIR /workspace
RUN pip install jupyterlab
EXPOSE 8888
ENTRYPOINT ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--no-browser"]

run.sh:

#!/bin/sh

docker build -t ml/jupyterlab .
docker rm -f ml-jupyterlab
docker run -d -p 8888:8888 -v $(pwd)/src:/workspace --name ml-jupyterlab ml/jupyterlab

until [[ "$url_info" =~ "token" ]]; do
    url_info=$(docker logs ml-jupyterlab --tail 1)
    sleep 0.1 
done

echo "$url_info"

Executing the following

$ chmod +x run.sh
$ ./run.sh

gets into an infinite loop as $url_info remains null


I would really appreciate any help I can get here.

Source: StackOverflow