Use a remote profile

I was wondering if it is possible to associate a default profile to an image and use this profile for every container which is started with this image?

Additionaly is there a way to set a profile from a remot host to a container launched from a remote host?
The only thing i could think of was this:

lxc launch <remote>:<image> -p <remote>:<some profile>

But I could not assign a remote profile to a container from a remote host.
Gives me the error (the profile does exist on the remote host):

Creating the container
error: Failed container creation:
 - <remote url>: Requested profile '<remote>:<some profile>' doesn't exist

The same command with only the image given did work:
lxc launch <remote>:<image>

Cheers Benj

On init/launch, the -p parameter (and same with -s and -n) is relative to the server the container is being created on. So “-p some-profile” will use “some-profile” on the server the container is created on.

As for associating profiles with images, I think it’s the first time we hear of this request. It shouldn’t be particularly hard to do and would effectively replace the “default” profile when an alternative is specified.

So it is not possible to use a profile from a remote on a local container (which is pulled from the same remote)?
Yeah i think this would be a nice feature :slight_smile:

Right, you can’t use a remote profile as LXD itself (the server) doesn’t know what a remote is and so wouldn’t have a way to keep things up to date. Even if it did, it would be extremely costly as profile resolution happens every time the container object is open internally.

Your best bet is to keep your profile in sync through “lxc profile copy” and then use that.

Okay thank you very much for your help!
If i try to copy a profile from a remote:

lxc profile copy <remote>:<profile> <new local profile>  

I then get the following error (even dough the launching of containers from the same remote is working):

error: The remote isn't a private LXD server

Did i miss something here?

Hmm, the copy seems to work fine here…

Can you post the output of “lxc remote list” (and tell me what remote name you were using) and also the output of that same “lxc profile copy” but with --debug?

I’d expect that error if either the source or target LXD instance is a “public” remote.

Output of lxc remote list:
I was using the instar remote.

+-----------------+------------------------------------------+---------------+--------+--------+
|      NAME       |                   URL                    |   PROTOCOL    | PUBLIC | STATIC |
+-----------------+------------------------------------------+---------------+--------+--------+
| images          | https://images.linuxcontainers.org       | simplestreams | YES    | NO     |
+-----------------+------------------------------------------+---------------+--------+--------+
| instar          | https://instar:8443                      | lxd           | YES    | NO     |
+-----------------+------------------------------------------+---------------+--------+--------+
| local (default) | unix://                                  | lxd           | NO     | YES    |
+-----------------+------------------------------------------+---------------+--------+--------+
| ubuntu          | https://cloud-images.ubuntu.com/releases | simplestreams | YES    | YES    |
+-----------------+------------------------------------------+---------------+--------+--------+
| ubuntu-daily    | https://cloud-images.ubuntu.com/daily    | simplestreams | YES    | YES    |
+-----------------+------------------------------------------+---------------+--------+--------+

And lxc profile copy --debug instar:profile instar-profile returns the same error:
Also --verbose prints the same error.

error: The remote isn't a private LXD server

Right, that’s because your “instar” remote is marked as “public”. That limits API interactions to what’s publicly visible without authentication (effectively just public images).

Removing and re-adding the remote without the --public flag should fix that for you.

Awesome!
I also had to set the core.trust_password on the “instar” remote:

lxc config set core.trust_password [password]

Thanks for your help. :smile:

Cheers Benj