ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Managing LXD images

    Scheduled Pinned Locked Moved IT Discussion
    lxd
    1 Posts 1 Posters 847 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RomoR
      Romo
      last edited by Romo

      As @scottalanmiller tells us in the introductory post, lxd is completely image based. Each new container we create must be based from an image, either manually made or premade and downloaded from a remote location.

      After installation, lxd by default sets us with remote image locations so we can start downloading images to our local store. We can check the default remote list with the following command.

      ~$ lxc remote list
      +-----------------+------------------------------------------+---------------+--------+--------+
      |      NAME       |                   URL                    |   PROTOCOL    | PUBLIC | STATIC |
      +-----------------+------------------------------------------+---------------+--------+--------+
      | images          | https://images.linuxcontainers.org       | simplestreams | 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    |
      +-----------------+------------------------------------------+---------------+--------+--------+
      

      To check the images available in each remote, we can run lxc image list remotename: and a list of all available image containers will be listed, but this is many times not practical due to the amount of images available in the remotes. So you can just visit the url shown in the remote list in your browser of choice to view the available images.

      From the cli

      ~$ lxc image list images:
      

      0_1512096675269_c91647a3-4aac-42c2-b583-4db3c630483f-imagen.png

      Visiting the remote url: https://images.linuxcontainers.org
      0_1512096879978_295b3839-4b8a-42a4-bbaa-2c775aa3a5c0-imagen.png

      To get images to our local store and start building containers the basic command is lxc image copy remoteName:imageDistribution/imageRelease/imageArchitecture local: imageArchitecture being optional.

      This basic command does its job just fine but has a few drawbacks in my opinion. It forces us to call the imageDistribution/imageRealease image name each time we want to create a container and the image must be downloaded again manually if we want to have the latest container.

      How can we fix this, easy addding two extra parameters to our basic image download command. Here is an example that will be downloading a Fedora/27 image from the "images:" remote, giving it our custom alias and having it auto updating daily.

      ~$ lxc image copy images:fedora/27 local: --alias f-27 --auto-update
      

      Giving our images an alias has two benefits, shorter commands when creating containers and the ability to delete images by the alias instead of deleting by using the image Fingerprint which is not user friendly.

      # List images in our local store and compare the alias vs fingerprint
      
      ~$ lxc image list
      +---------+--------------+--------+-----------------------------------------+--------+----------+-----------------------------+
      |  ALIAS  | FINGERPRINT  | PUBLIC |               DESCRIPTION               |  ARCH  |   SIZE   |         UPLOAD DATE         |
      +---------+--------------+--------+-----------------------------------------+--------+----------+-----------------------------+
      | f27     | b25c1b1b6831 | no     | Fedora 27 amd64 (20171201_01:27)        | x86_64 | 63.61MB  | Dec 1, 2017 at 3:01am (UTC) |
      +---------+--------------+--------+-----------------------------------------+--------+----------+-----------------------------+
      

      Finally to create and start our container based on our Fedora 27 image we just run.

      ~$ lxc launch f27 yourcontainername
      Creating yourcontainername
      Starting yourcontainername
      ~$
      
      1 Reply Last reply Reply Quote 4
      • 1 / 1
      • First post
        Last post