Linux – Docker attach to curses process

containersdockergnu-screenlinuxterminal

I'm trying to use docker attach to attach to curses-based graphical process:

$ docker run --name irssi -it pandrew/irssi irssi

When you detach from this process using ^P^Q and reattach with docker attach irssi it looks like nothing happened. But, the process does reattach, because you can type commands and slowly you can build the graphical interface back up by triggering redraws. Nevertheless, the behavior of the process is strange after the re-attaching.

However, if you initially run the process inside a screen, everything works fine:

$ docker run --name irssi -it ${PREVIOUS_IMAGE_PLUS_SCREEN} screen irssi

You can detach and reattach from the container and something about screen causes the irssi session to behave fine. It appears that irssi has some capacity to check to see whether it's "dirty", and to redraw the screen: https://github.com/irssi/irssi/blob/master/src/fe-text/irssi.c#L123.

Can anyone help explain what's going on here? Thank you.

Best Answer

When you re-attach to a fullscreen app, that app needs to redraw. Screen is good at figuring out when it's re-attached, and re-drawing itself -- generally by listening for SIGWINCH which indicates that the terminal size has changed. It may have some additional functionality for monitoring its terminal that allows it to succeed here where irssi does not.

Based on the last suggestion in the irssi tips page, you should be able to type /redraw in irssi to redraw the screen, or bind that to ^L with /bind ^L redraw.

Related Topic