How to update LXD container Ubuntu image from 16.04 to 18.04

To update an LXD container running Ubuntu 16.04 to 18.04, you can use the lxc command-line tool. Here are the general steps to follow:

  1. Start by making a snapshot of the container, so that you can roll back if anything goes wrong during the update process:
lxc snapshot <container name> <snapshot name>
  1. Then update the container’s package list and upgrade the packages to the latest version:
lxc exec <container name> -- apt-get update
lxc exec <container name> -- apt-get dist-upgrade
  1. After upgrading the packages, reboot the container:
lxc exec <container name> -- reboot
  1. After the container has rebooted, check the version of Ubuntu:
lxc exec <container name> -- lsb_release -a
  1. if the version is still 16.04 then you have to change container’s image to 18.04. To do this, stop the container:
lxc stop <container name>
  1. Then remove the container:
lxc delete <container name>
  1. And finally, create a new container using the 18.04 image:
lxc launch ubuntu:18.04 <container name>
  1. Finally, you can restore the container’s data from the snapshot you created earlier:
lxc restore <container name> <snapshot name>

Note: These are just general steps, for more detailed and accurate steps please refer to the official documentation of LXD and Ubuntu.

(Tramadol)

Leave a Comment