sorry about the missing comments. It's quite simple, but very-python-oriented.

lines = list of lines, which has to be present in order to finish
bad_lines = list of lines which can't be present in the output
log = list of lines from the docker log $ID output

I'm `while` iterating until the timeout.
1) get new output
2) try to remove all (good) lines from the output, I don't care of the output order. When the message is present multiple times, remove deletes just one occurrence. In case the line is not in the output, it raises ValueError, which is caught and we are back in while loop
3) check all bad_lines for presence, if present, raise exception
4) break __this is important__ :-) When we reach break, while is interrupted thus the `else` part of while is not executed.

`while-else` is executed when while condition was the reason for finishing the loop (no brakes), so we run out of time.