How to update LXD container Ubuntu image from 16.04 to 18.04

I run my app inside Ubuntu Linux 16.04 LTS lxd Linux container. To upgrade Ubuntu 16.04 to 18.04 LTS container, I run do-release-upgrade command, but I am getting the error message that read as “Must be connected to a terminal.” How do I fix this problem to upgrade from Ubuntu Linux 16.04 to 18.04 image?

Introduction – The LXD container hypervisors supported and created by Ubuntu team. It provides 25% faster performance than ESX. This page shows how to upgrade LXD container Ubuntu 16.04 LTS image to 18.04 LTS image.

How to update LXD container

kbd { display: inline-block; margin: 0 .1em; padding: .1em .6em; font-family: Arial,”Helvetica Neue”,Helvetica,sans-serif; font-size: 11px; line-height: 1.4; color: #242729; text-shadow: 0 1px 0 #FFF; background-color: #e1e3e5; border: 1px solid #adb3b9; border-radius: 3px; box-shadow: 0 1px 0 rgba(12,13,14,0.2), 0 0 0 2px #FFF inset; white-space: nowrap;}

The procedure to upgrade LXD container Ubuntu image named utls-www is as follows:

  1. Log in to your Ubuntu container, run: lxc exec utls-www bash
  2. Update Ubuntu Linux Software, run: apt update && apt upgrade
  3. Make Ubuntu Linux container snapshot, run: lxc snapshot utls-www
  4. Finally update LXD container Ubuntu image from 16.04 to 18.04, run: lxc exec utls-www -- script /dev/null -c do-release-upgrade

Commands to upgrade LXD container Ubuntu image

Let us see all commands in details.

Step 1 – Log in to your Ubuntu container

To list currently running Linux containers, run:
$ lxc list
Gain root shell access for container named utls-www, run:
$ lxc exec utls-www bash

Step 2 – Update utls-www container image

You must install all available updates for your release before upgrading, run apt command:
# apt update
# apt upgrade

Note down your your Ubuntu Linux container version and exit back to host:
# lsb_release -a
# exit

Step 3 – Create container snapshots

For backup purpose create container snapshot, run:
$ lxc snapshot utls-www
$ lxc info utls-www

Step 4 – Upgrade Ubuntu Linux container image from 16.04 LTS to 18.04

Now we have a backup for our utls-www container. It is time to start the upgrade procedure. Run:
$ lxc exec utls-www -- script /dev/null -c do-release-upgrade

Press the [Enter] key. Do you want to continue?

Do you want to continue upgrading Ubuntu Linux container image?

You may be prompted to replace or keep existing config files. For example, I use utls-www for Nginx/PHP-fmp service. I am going to keep nginx.conf and other config files when prompted:
The default action is to keep your current version. I am going to keep my currently-installed version by pressing N or O

Ubuntu Linux container image upgrade is complete. Do you want to reboot the Linux container?

You can manually restart the container too:
$ lxc restart utls-www

Step 5 – Verification

Now our utls-www Linux container image updated to the latest version of Ubuntu. It is time to verify that everything is working as expected. Log in to your container:
$ lxc exec utls-www bash
To find OS version in Ubuntu Linux, run:
# lsb_release -a

Verify that all services are running and ports are open with help of ss command/netstat command and grep command/egrep command:
# ss -tulpn
# ps aux
# tail -f /var/log/nginx/error.log
# grep 'something' /var/log/nginx/sxi.io_access.log
# egrep -i 'err|crit|warn' /var/log/nginx/sxi.io_error.log


And there you have it. Ubuntu Linux container image has been upgraded from 16.04 LTS to 18.04 LTS.

(adsbygoogle = window.adsbygoogle || []).push({});

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...