Managing LXD containers – advanced options
In this recipe, we will learn about some advanced options provided by LXD.
How to do it…
Follow these steps to deal with LXD containers:
Sometimes, you may need to clone a container and have it running as a separate system. LXD provides a
copy
command to create such clones:$ lxc copy c1 c2 # lxc copy source destination
You can also create a temporary copy with the
--ephemeral
flag and it will be deleted after one use.Similarly, you can create a container, configure it as per you requirements, have it stored as an image, and use it to create more containers. The
lxc publish
command allows you to export existing containers as a new image. The resulting image will contain all modifications from the original container:$ lxc publish c1 --alias nginx # after installing nginx
The container to be published should be in the stopped state. Alternatively, you can use the
--force
flag to publish a running container, which will internally stop the container...