Installing LXC or LXD on PureOS - is it possible?

Hi
I am using PureOS based on Debian buster/sid

I can install lxc fine and create containers.
when I check the container’s details there is no network connection no IP

I know that PureOS does not support any i386 packages.
Could that be the problem?

Thanks

I assume you are using LXD.
When you have a managed network, LXD arranges for the containers to get an ip address from a 10.x.x.x network.
If you ran sudo lxd init, then you are asked whether you want LXD to manage containers for the networking. Did you enable those?

Hi @simos
thanks for your reply

I made so many trials and had so many errors I decided to re install my system and here’s where I am at

OS - PureOS - based on debian buster/sid
bear in mind PureOS does not have all the debian source lists because it is totally FOSS

This time I installed lxd rather than lxc and installed it via snap

here’s what’s on my screen:

sherab@Sherab-PureOS:~$ snap list
Name  Version  Rev    Tracking  Publisher   Notes
core  16-2.38  6673   stable    canonical✓  core
lxd   3.12     10601  stable    canonical✓  -
sherab@Sherab-PureOS:~$ sudo lxd init
sudo: lxd: command not found
sherab@Sherab-PureOS:~$ cd /snap/
sherab@Sherab-PureOS:/snap$ ls
bin  core  lxd  README
sherab@Sherab-PureOS:/snap$ less README 
sherab@Sherab-PureOS:/snap$ cd lxd/
sherab@Sherab-PureOS:/snap/lxd$ ls
10601  current
sherab@Sherab-PureOS:/snap/lxd$ 

I hope you could advise how i should continue.

thanks in advance
sherab

sudo /snap/bin/lxd init

If that works then the problem is simply that /snap/bin is missing from your PATH.

@stgraber
Very cautiously I think it works!!
Many thanks.
Can I please ask two questions?

  1. When I am adding this to the path
    $ export PATH=$PATH:/snap/bin/lxd
    # export PATH=$PATH:snap/bin/lxc

it does not remain permanent - do I add it in .bashrc or elsewhere?? where?

  1. Now that I have a ubuntu 18.04 running in a container - can install a GUI application in it?? if so how?

Thanks for helping

on Ubuntu this is done by adding a file under /etc/profile.d containing:

# shellcheck shell=sh

# Expand $PATH to include the directory where snappy applications go.
snap_bin_path="/snap/bin"
if [ -n "${PATH##*${snap_bin_path}}" -a -n "${PATH##*${snap_bin_path}:*}" ]; then
    export PATH=$PATH:${snap_bin_path}
fi

# Ensure base distro defaults xdg path are set if nothing filed up some
# defaults yet.
if [ -z "$XDG_DATA_DIRS" ]; then
    export XDG_DATA_DIRS="/usr/local/share:/usr/share"
fi

# Desktop files (used by desktop environments within both X11 and Wayland) are
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for
# snappy applications' desktop files.
snap_xdg_path="/var/lib/snapd/desktop"
if [ -n "${XDG_DATA_DIRS##*${snap_xdg_path}}" -a -n "${XDG_DATA_DIRS##*${snap_xdg_path}:*}" ]; then
    export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${snap_xdg_path}"
fi

if this directory don’t exist in your distro, you can add these lines to .bashrc indeed.

Hi again @gpatel-fr
the file you mentioned exist as the following location:
/etc/profile.d/app-bin-path.sh

And it is exactly like the one you shared

should have modified your path, unless you did not logout/login
Unless your distro don’t use /etc/profile.d. It should use /etc/profile though, I think it’s in the official LSB spec.
Is there something like

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

in your /etc/profile file ? Looking at the Linux Standard Base; the /etc/profile.d is NOT in it, so maybe snap install is creating blindly a app-bin-path.sh expecting it to be picked by /etc/profile, while in your distro the /etc/profile file don’t refer to the profile.d directory. Hope I am clear :slight_smile:

Edit: I did look into an old LSB spec, in the last one, profile.d is specified and should be taken in account.

Hi again @gpatel-fr
thanks for your reply.

I am not sure what you are saying but :slight_smile:
/etc/profile
Here is the content of /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr
/games"
export PATH

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

You’d have noticed it is slightly different than the one you posted in as much as it contains the following line at the top

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr
/games"
export PATH

any ideas what to do next?

you really should have this /snap/bin in your path :-/
In your place I’d try to copy /etc/profile in your home directory, then in this same directory edit this file to add

echo $PATH

before and after the

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

part, then save and run it with
. ./profile
what is displayed then ?

Thanks @gpatel-fr
I think it is now solved by @simos in a different post GUI Apps in LXD container

thank you for your help