1

I have been trying to attach and detach screen sessions in LXD-managed containers; initially, I wasn't able to even start one, but that problem was answered here.

However, being able to start a session, then detach it, isn't sufficient. To work with screen sessions, one must be able to re-attach to a certain session.

I can initiate a session with

lxc exec my-ubuntu -- sh -c "exec >/dev/tty 2>/dev/tty </dev/tty && /usr/bin/screen -s /bin/bash"

but then, when I issue

lxc exec my-ubuntu -- sh -c "exec >/dev/tty 2>/dev/tty </dev/tty && /usr/bin/screen -x"

either nothing at all happens (I just get another command line) or, if I've issued the first command more than once, I get There are several suitable screens on: followed by a list of sessions, and a suggestion to re-attach to them with "screen [-d] -r [pid.]tty.host". However, that also fails silently. I've also tried to issue

lxc exec my-ubuntu -- sh -c "exec >/dev/tty 2>/dev/tty </dev/tty && /bin/bash"

and then screen -x from the resulting terminal, to no avail.

What can I do?

EDIT: If I use the last command to get a terminal inside my container my-ubuntu, I can initiate screen sessions just typing screen, and detach them with CTRL-a followed by d. However, screen -x then fails silently just as described above, and if I try CTRL-a followed by n from within a session, it reports no other window.

Jonathan Y.
  • 1,034
  • 1
  • 16
  • 35
  • I'd like to mention that one way around the entire issue is to open the screen on the host, before attaching to the container. Unless you have multiple levels of nested containers, there aren't many disadvantages to that approach that I can see. – Jonathan Y. May 09 '16 at 11:23
  • another workaround: connect to container via ssh, even though it's local. – Scott Mar 07 '19 at 13:25

1 Answers1

0

I suggest:-

lxc exec <container> --mode=interactive -- bash
Simon Banks
  • 1,177
  • 4
  • 19