set the LINES and COLUMNS environment vars

also make connection to the container more robust