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:


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


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 

echo "$url_info"

Executing the following

$ chmod +x
$ ./

gets into an infinite loop as $url_info remains null

I would really appreciate any help I can get here.

Source: StackOverflow