Linux

How to update LXD container Ubuntu image from 16.04 to 18.04

[ad_1]

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

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

How to log in into Ubuntu Linux container

Step 3 – Create container snapshots

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

How to make Linux container snapshot

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
How to update LXD container Ubuntu Linux image
Press the [Enter] key. Do you want to continue?

Do you want to continue upgrading Ubuntu Linux container image?
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:

Install a new version of config files
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?
Reboot Ubuntu Linux container image
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
Ubuntu Linux container image upraded to 18.04 LTS
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/www.cyberciti.biz_access.log
# egrep -i 'err|crit|warn' /var/log/nginx/www.cyberciti.biz_error.log

Conclusion

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

[ad_2]

Facebook Comments

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button