How to disconnect from lxc-console
Solution 1
Yes, Ctrl-aq, should work by default, however no, lxc-console
does not actually use screen
to accomplish its console behavior. In fact, you might be encountering a conflict if you are using screen since it also uses Ctrl-a as a prefix. If you're inside screen
but don't realize it then you'll need to type Ctrl-a a q since the default behavior of screen
is that you have to type Ctrl-a a to actually send ^a
to the shell running inside of it. You can change the prefix for escape by passing the -e
or --escape=PREFIX
option to lxc-console
.
Also, it appears there may be a bug in lxc-start
so that if it immediately goes into console mode when you start the container you can't using Ctrl-a q to escape-- in fact, all the control characters seem to be screwed up and print to the screen instead of behaving the way you expect. One workaround is to run it with the -d
or --daemon
option so that it doesn't immediately start a console, and the connect to it by hand:
lxc-start -d -n container-name
lxc-console -n container-name
Solution 2
What I did to stop the container
- Open a new session.
- Login as root.
- Check the container status.
lxc-stop -n <name of the container>
This will stop the container.
Related videos on Youtube
robbyt
People have paid me to fix stuff since the 90s. I currently reside in NYC.
Updated on September 18, 2022Comments
-
robbyt almost 2 years
I'm working with lxc in Ubuntu 12.04, and it's really great. However, I am unable to disconnect from a
lxc-console
session after I've connected. I read somewhere that Ctrl-aq will disconnect me from the console but it doesn't seem to work.Should I be running
lxc-console
viascreen
instead?-
Martin Serrano about 8 yearsyou can also do an
lxc-stop
from another shell
-
-
robbyt almost 12 yearsNo, this does not work. I've been using screen so that I can disconnect from lxc-console. Also, the link that you posted does not have any information about this problem.
-
El Yobo almost 12 years"Detach screen: C-a d or C-a C-d" - help.ubuntu.com/community/LXC#Mini_screen_how-to; not sure what to do if that's not working.
-
aculich over 11 years@ElYobo No,
lxc-console
does not actually usescreen
, it just has similar behavior and by default actually uses a key that conflicts withscreen
's as described here. -
Jay Taylor almost 11 years<kbd>Ctrl-a q</kdb> does not have any effect on a connected console with lxc version 0.9.0
-
Florian Heigl almost 8 yearsif the lxc devs should ever wonder why docker had a billion times higher adoption, this bug is one of the main reasons.
-
AlpSenel over 6 years@FlorianHeigl While I agree with your sentiment about this bug being ugly, the true reasons for that are attitudes: bugs.debian.org/cgi-bin/bugreport.cgi?bug=768073 access.redhat.com/articles/1365153 access.redhat.com/discussions/2772171 (and numerous other occasions where RedHat responds to "LX(C|D)?" with "No, Docker!" (note that these are top Google results for "LXD Debian", and "LXD Redhat queries").