So I have the following script:
#!/bin/bash
docker run -itd -p 8888:8888 --name notebook --mount type=bind,source="$(pwd)",target=/home/jovyan/work jupyter/datascience-notebook:latest
sleep 10s
link=$(docker logs --until=5s notebook | grep -o -m 1 'http://127.0.0.1:[0-9]*/lab?token=[0-9a-z]*')
var=$(date)
echo $var
echo $link
and when I run it with bash startup.sh it does not print out link variable while it does print var. The crazy thing is if I run these commands individually on my terminal it does set link (which is how I wrote the script in the first place). Also that 10 second sleep is more than enough for the docker logs to be available.
Am I missing something here? is there something special about docker that's causing this? I'm so confused.