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

  1. Open a new session.
  2. Login as root.
  3. Check the container status.
  4. lxc-stop -n <name of the container>

This will stop the container.

Tags:

Linux

Ubuntu

Lxc