LXD API - How to create a container

Hi,

I’m trying to use the API of LXD. I read the API docu at https://lxd.readthedocs.io/en/latest/rest-api/#rest-api and still have some questions.

  1. Why are the alias not the same on remote and local?
  2. How can I pull an image and create a container in one step?

To the first question:
I played with the api and downloaded an image with “lxc image copy ubuntu:lts local:” but the alias is not set. Can I do that with a parameter?

To the second question:
I found this snippet on the same url:

"source": {"type": "image",                                         // Can be: "image", "migration", "copy" or "none"
           "mode": "pull",                                          // One of "local" (default) or "pull"
           "server": "https://10.0.2.3:8443",                       // Remote server (pull mode only)
           "protocol": "lxd",                                       // Protocol (one of lxd or simplestreams, defaults to lxd)
           "certificate": "PEM certificate",                        // Optional PEM certificate. If not mentioned, system CA is used.
           "alias": "ubuntu/devel"},   

What is the correct url for the server if I want to download the lts ubuntu version from the standard lxc remote? This would avoid scripting because it’s just one call.

Thanks for this great software :slight_smile:

As you haven’t said what language or library you are trying with its hard for me to give more specific advise but, you should try adding --debug to the end of your lxc commands it will show you all the API calls to LXD which should help you develop against the API!

great, didn’t know that! I develop in c# with restsharp.