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:
- Log in to your Ubuntu container, run: lxc exec utls-www bash
- Update Ubuntu Linux Software, run: apt update && apt upgrade
- Make Ubuntu Linux container snapshot, run: lxc snapshot utls-www
- 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?
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:
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/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.