Create LXD image from an existing snapshot.
Create an instance.
$ lxc launch ubuntu:groovy jenkins
Update it using bash, ansible, or other automation utility.
$ lxc exec jenkins bash
Create snapshot.
$ lxc snapshot jenkins jenkins_snapshot_20200404
Create an image and set desired properties.
$ lxc publish jenkins/jenkins_snapshot_20200404 --alias local_jenkins description="Jenkins application"
List images.
$ lxc image list
+---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCHITECTURE | TYPE | SIZE | UPLOAD DATE | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | local_jenkins | 643f21fc40b0 | no | Jenkins application | x86_64 | CONTAINER | 1607.19MB | Apr 4, 2021 at 3:04pm (UTC) | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | | 6ac59eac2988 | no | ubuntu 20.10 amd64 (release) (20210325) | x86_64 | CONTAINER | 364.59MB | Mar 29, 2021 at 9:28pm (UTC) | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | | 46701fa2d99c | no | ubuntu 20.04 LTS amd64 (release) (20210325) | x86_64 | CONTAINER | 360.90MB | Mar 28, 2021 at 2:18pm (UTC) | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+
Inspect created image.
$ lxc image info local_jenkins
Fingerprint: 643f21fc40b0bd4393a0542ccf408841aaf6ee5133f7469dbf6d87df1fb50c5b Size: 1607.19MB Architecture: x86_64 Type: container Public: no Timestamps: Created: 2021/04/04 15:04 UTC Uploaded: 2021/04/04 15:04 UTC Expires: never Last used: never Properties: description: Jenkins application Aliases: - local_jenkins Cached: no Auto update: disabled Profiles: - default
Export image.
$ lxc image export local_jenkins local_jenkins
Inspect created archive file and share it.
$ ls -lh local_jenkins.tar.gz
-rw-rw-r-- 1 milosz milosz 1.6G Apr 4 15:05 local_jenkins.tar.gz
Now, you can import it on a different server.
$ lxc image import local_jenkins.tar.gz --alias local_jenkins
Display images.
$ lxc image list
+---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCHITECTURE | TYPE | SIZE | UPLOAD DATE | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | local_jenkins | 643f21fc40b0 | no | Jenkins application | x86_64 | CONTAINER | 1607.19MB | Apr 4, 2021 at 3:06pm (UTC) | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+ | | 46701fa2d99c | no | ubuntu 20.04 LTS amd64 (release) (20210325) | x86_64 | CONTAINER | 360.90MB | Mar 28, 2021 at 2:58pm (UTC) | +---------------+--------------+--------+---------------------------------------------+--------------+-----------+-----------+------------------------------+
Launch an instance using this image.
$ lxc launch local_jenkins jenkins