# LXD Custom Images Revisted

**URL:** https://discussion.scottibyte.com/t/lxd-custom-images-revisted/267
**Category:** Uncategorized
**Created:** [August 19, 2023, 6:56pm UTC](https://discussion.scottibyte.com/t/lxd-custom-images-revisted/267 "2023-08-19T18:56:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)
#### Post date: [August 19, 2023, 6:56pm UTC](https://discussion.scottibyte.com/t/lxd-custom-images-revisted/267/1 "2023-08-19T18:56:55Z")

</div>

All LXD Containers and LXD Virtual Machines are created from images. A year and a half ago I did a video entitled “LXD Custom Images”. This tutorial expands on that subject and focuses on how you can use LXD Custom Images.

LXD Containers and LXD VM’s are faster to launch because they come from images and do not have to go through an Operating System installation. The LXD repository for the majority of LXD images is located [here](https://images.linuxcontainers.org/). Images can also come from LXD servers on your network. These images can be customized and used as a starting point to create other containers.

If you have more than one LXD server on your network that you have authorized, you can list the available servers:

```auto
lxc remote list

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/95185e80d947fe0253d66016d3d8e1a59516f71f.jpeg)

To authorize another LXD server to be added to your list of manageable servers:

```auto
lxc remote add vmsfog 172.16.1.57

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/18c7a9865843984a5a584c0fecbf83340ea17a36.png)

Once you have a LXD server added to your remote list, you can interact with the remote server:

```auto
lxc list vmsfog:

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/2927665b819bd78bf6b8d2862c0900f936dca080.png)

Another example:

```auto
lxc launch ubuntu:22.04 vmsfog:test2

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/a31829e549315b8e860dacdf929911aab323ff31.png)  
You can also authorize access to a remote LXD server by adding a trust in the form of a certificate. We did that on the tutorial “LXDWare LXD Dashboard” by obtaining a certificate from the LXD Dashboard Server and adding it to the LXD Server we wanted to manage:

```auto
lxc config trust add lxdware.crt

```

Recall that you can list containers on your local LXD Server:

```auto
lxc list

```

![image](https://discussion.scottibyte.com/uploads/default/original/1X/83ecf978c93af3dc8beb953263eea708dbdf414e.png)

You can also display a list of the images on your server that can be used to create LXD containers and LXD Virtual machines:

```auto
lxc image list

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/117c4aea1ade8f8ccdaf8452fdb6323889eb0410.jpeg)

An example of creating a container using an image from the list above:

```auto
lxc launch mycoolimage test

```

You can also list images on another server on your network assuming you have authorized access:

```auto
lxc image list vmsrain:

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/956b3dbcfda8dddbe6b1257e32385c8734dd1745.jpeg)

To list all of the images on the public LXD Image repository:

```auto
lxc image list images:

```

You can make that easier to read:

```auto
lxc image list images: | more

```

You can also list images from just one distro:

```auto
lxc image list images: | grep -i 'debian'

```

A much neater display of all images can be displayed by listing images by “alias” name:

```auto
lxc image alias list images:

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/411408dee639b2dfe480adf57d04a499a0b36ee8.png)

You can also list information about a particular image on your LXD Server:

```auto
lxc image info mycoolimage

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/0d29e4da1be2d42a086106b079ff51abd21b5812.jpeg)

To export a copy of a custom image that you can import on another LXD server later:

```auto
lxc image export mycoolimage mycoolimage

```

![image](https://discussion.scottibyte.com/uploads/default/original/1X/e693caf8b1ea8623d830af2a429218fede8a492f.png)

You can delete an image that you no longer need:

```auto
lxc image delete mycoolimage

```

To import the saved image that we exported (Image alias names cannot have spaces in the name):

```auto
lxc image import mycoolimage.tar.gz --alias=mycoolimage

```

To create a custom image, you start by just creating a normal container:

```auto
lxc launch ubuntu:22.04 mytest

```

Move inside of the container:

```auto
lxc shell mytest

```

At this point, you can create user accounts, install programs and create data files. The actual modifications to a given container can be the basis for a LXD Image.

As an example, I have a LXD image with the “scott” account and with Docker installed as a starting point (image).

To create a custom image, you exit out of the shell in the container back to your LXD host prompt:

```auto
exit

```

![image](https://discussion.scottibyte.com/uploads/default/original/1X/a64876c72197e11341113eab53e74df05bc2404a.png)

Stop the container that you want to image:

```auto
lxc stop mytest

```

Create an image of your container (I named mine “custom-image”):

```auto
lxc publish mytest --alias custom-image

```

You can now create a new container based on this customized image:

```auto
lxc launch custom-image new-container

```

You will recall that you can make “point-in-time” snapshots of a container with the snapshot command (I called my snapshot “snapshot”):

```auto
lxc snapshot new-container snapshot

```

Let’s now assume that I made several changes to “new-container” and I wanted to make an image of the container before the changes when I did the snapshot:

```auto
lxc publish new-container/snapshot --alias my-image-from-a-snapshot

```

In summary, images can be created from containers or from container snapshots. Then, images can be used to create containers. Images are used as a starting point to create containers and are a very powerful configuration control tool.
