How to log into lxc container?

Solution 1:

login to container

lxc exec <container-name> -- sudo --login --user <username>

get the shell prompt of the container

lxc exec <container-name> -- sudo /bin/bash

Solution 2:

You can also use ssh command to login to LXC-container:

ssh lxcuser@container_ip_address

To find out the LXC IP-address you can use this:

ssh ubuntu@`sudo lxc-info -iH -n CN`

where CN is the container name and 'ubuntu' is the user acc in the LXC.

Solution 3:

lxc-start -n <container_name> -d
lxc-attach -n <container_name>

does the trick

Solution 4:

You need to enter the password for the "sudo" command to gain root privilege, in order to run lxc-start. It is not the login prompt for the container itself.