Skip to content
Kabouik edited this page Mar 2, 2020 · 10 revisions

Creating a container

Creating a linux container on sailfishOS is as simple as:

# lxc-create -t sfos-download -n mycontainer

The download template will show you a list of distributions, versions and architectures to choose from. A good example would be "debian", "sid" (unstable) and "arm64".

It is possible to skip shell interaction by providing parameters to sfos-download as shown below:

# lxc-create -t sfos-downlaod -n mycontainer -- --arch armhf --dist debian --release sid

For your first LXC experience, we recommend using a recent supported release, such as "debian sid/bullseye", "ubuntu bionic/cosmic".

After container's creation completed, you'll find the container config file on /var/lib/lxc/mycontainer/config and the container rootfs directory inside /home/.lxc/mycontainer.

sfos-download template is configured by default to store LXC's downloads cache inside /home/.lxc/lxc_cache, it is safe to delete this directory after creation in order to free up some storage.

Start your new container

You can start your freshly created container with:

# lxc-start -n mycontainer

Get container's informations

It is possible to get some useful informations about your container such as state, pid, cpu usage, memory usage and kmem usage as follows:

# lxc-info -n mycontainer

Attach to your container

to start a shell session on "mycontainer"

# lxc-attach -n mycontainer

Stop your container

# lxc-stop -n mycontainer

Freeze your container

It is possible to freeze containers in order to save battery life when unused as shown below:

# lxc-freeze -n mycontainer

Unfreeze your container

You can then restore your container state with:

# lxc-unfreeze -n mycontainer

Create a snapshot of your container

You can save the current state of your container as a snapshot to restore it later or create new containers from it:

# lxc-snapshot -n mycontainer mysnapshotname

List snapshots for your container

# lxc-snapshot -n mycontainer -L

Restore a snapshot of your container

To restore a previous snapshot (beware, this will overwrite the current state of your container unless you created another snapshot of it):

# lxc-snapshot -n mycontainer -r mysnapshotname

Optionally, you can create a new container from the snapshot with the following command instead of altering the parent container (not tested):

# lxc-snapshot -n mycontainer -r mysnapshotname -N mycontainer2

Destroy your container

# lxc-destroy -n mycontainer

References

Clone this wiki locally