How to update LXD container Ubuntu image from 16.04 to 18.04

Originally published at:

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?