Does anyone here use LXD/Incus? What do you do if you want to find the IP address of an instance, but incus list
does not give you one? I am not sure what would be stopping one from being issued since that is how I have found that information before.
I am just a student trying to learn about them and do stuff. I often just find the IP of the container and then ssh
in as that feels natural, but perhaps I am cutting against the grain here.
But that then leaves me as root, is there a way to just have a normal user? Or is that also not really intended?
Well, it’s a container, in most situations you would be running as root because the root inside the container is an unprivileged user outside it. So in effect the root inside the container will only be able to act as root inside that container and nowhere else. Most people simply do it that way and don’t bother with it.
If you really want there are ways to specify the user… but again there’s little to no point there.
lxc exec container-name --user 1000 bash
lxc exec container-name -- su --shell /bin/bash --login user-name
For your convenience you can alias that in your host’s ~/.bashrc
with something like:
lxcbash() { lxc exec "$1" -- sudo --login --user "$2"; }
And then run like:
lxcbash container-name user-name
I guess that does make sense. Part of what I had in mind was having different instance for different projects. I guess in my mind it gives me a reason to have and practice multiple as well as feeling cleaner (keeping compiler and stuff off host). I will try out your advice when I get home. Thank you so much!
I use LXD (too lazy to move to Incus at the moment) for this exact purpose. It’s definitely nice having a greater degree of isolation between the various projects I’m working on — especially when working with confidential information from clients. Depending on what you’re looking to do there are simpler ways to manage isolation between projects like chroot and nspawn or Nix’s environments. Then again by using LXD/Incus you get that plus lots of other useful tools baked in.
Regarding not getting an IP address have you checked your base configuration to see if dhcp has been configured for the bridge? If that isn’t the issue then all I can think of is that you somehow deleted the interface and should check the container config.
That said the commands provided above are how I usually access the container command line. For coding I use code-server to put VS Code in a browser. I’m sure there are better options and look forward to the suggestions.
Keep going and learning!