Is it better to start a container from an image or from another container?

Hello all,

In terms of performance and maintainability, is it better to start a container from an image or from another container?

LXD comes with two default repositories of images, ubuntu: and images:.
These images are updated frequently, therefore if you launch one now, you get only a few packages in apt upgrade.

Once you start a container from an image, it becomes a running container. It updates itself.
Specifically, the package unattended-upgrades will upgrade by default all security-related packages.
If you want other packages to upgrade as well, you have to set it up yourself.

It makes sense to create your own container image from a container, if there are any worthwhile changes in that container image. For example, if you are launching many WordPress website, you can create a container image with WordPress preinstalled and somewhat preconfigured.

Otherwise, just use the images from the default repositories.

I’ll toss in my $0.02.

We use images as historical versioning and use containers on our admin server for immediate deployment. This allows us to easily update our baseline container w/out having to create a new image each time.

If you use images exclusively to manage your baseline container, you have to:

  • Launch your image (i.e. v1.01)
  • Make your changes
  • Shutdown your image
  • Create an image from v1.02 (this can take a while depending on CPU/SSD speeds)

If you update your image often (i.e.: during early release cycles), this can become very tedious. For our environment, we setup an admin server to host our images then launch a baseline image (i.e.: v1.01). When we need to make changes, we simply copy v1.01 to v1.02 (“lxc copy”) then make the necessary changes. When we need to deploy the updated version, we simply copy the local image to a remote server (lxc copy <admin_server>:containerv102 <remote_server>: ). The benefit to this approach is the ability to quickly update and deploy our images. Once we are comfortable with the updated version, we create a baseline image and keep it on the admin server.

Hope this helps.


…forgot to mention.

If you use BTRFS or ZFS to host your containers, making a copy of a container is instantaneous and uses almost zero additional space (simply a snapshot). Conversely, each image is considered a full, standalone “tar.gz” file and could occupy lots of space on your server. Keep this in mind if you are space constraint on your server…

Many thanks, this is exactly what I was looking for…

I am using indeed ZFS and have noticed that copying a container was much faster, this is why I wanted to ask for some user feedback.