How-to upgrade LXC container after `do-release-upgrade` to Wily?
Solution 1
I also google similar question, and find your question. :) Before I start testing, I create snapshot for the container, in case I ruin something when I'm trying. Fortunately, the upgrade is very smooth.
I think container will not be upgrade automatically when host is upgraded.
I've just done an release upgrade from Wily to Xenial for my LXD container. Below is what I'm doing. I think it would be similar for LXC container.
Attach to containter console, you will be root; and you don't need to worry ssh service since you are using console:
$ lxc exec <container name> -- bash
First upgrade your software packages, especially for apt:
# apt-get update
# apt-get dist-upgrade
# reboot (maybe not needed)
if you don't have "do-release-upgrade":
# apt-get install ubuntu-release-upgrader-core
Then you can start upgrade:
# do-release-upgrade -m server
In case “do-release-upgrade” complains "Must be connected to a terminal.", I have no idea why this happens, I think this container bases on Ubuntu cloud image. So have to use a ssh connection and "sudo"s.
Solution 2
If I don't want/need to pass the upgrader code paths I do like the post that mentioned just replacing the release name in /etc/apt/sources.list.
But If I want/need do-release-upgrade to really run I just enable ssh. There might be easier ways to get convinced to have a proper console, but it is easy and works.
To do so do
# go into the container
lxc exec <container> bash
# set PasswordAuthentication yes here
vim /etc/ssh/sshd_config
# restart containers ssh
service ssh restart
# set a pw of the default ubuntu user
passwd ubuntu
# exit container and get the container IP
lxc info <container>
# connect to it via ssh
ssh ubuntu@<ip>
# run do-release-upgrade as you want
do-release-upgrade
Solution 3
Cannot comment on @alfred answer so sorry for new one.
"Must be connected to a terminal." complain can be solved with command:
exec >/dev/tty 2>/dev/tty </dev/tty
Than just run do-release-upgrade.
Related videos on Youtube
![Mausy5043](https://i.stack.imgur.com/C7OuQ.png?s=256&g=1)
Mausy5043
Expert asker of unanswerable questions. Hobbyist programmer since 1986
Updated on September 18, 2022Comments
-
Mausy5043 almost 2 years
I have just done a
do-release-upgrade -m server
fromLinux boson 3.19.0-31-generic #36-Ubuntu SMP Wed Oct 7 15:04:02 UTC 2015 x86_64 Linux-3.19.0-31-generic-x86_64-with-Ubuntu-15.04-vivid
to
Linux boson 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 Linux-4.2.0-16-generic-x86_64-with-Ubuntu-15.10-wily
I had imagined that the LXC containers would automagically be upgraded too. However, although
uname -r
returns4.2.0-16-generic
which confirms that the kernel is on Wily, doing anapt-get update
shows that the container is still pointed at the Vivid repository.do-release-upgrade
while attached to the container returnsbash: do-release-upgrade: command not found
.How do I upgrade the LXC containers too? Is there a tool available?
(I don't have X installed)
-
Mausy5043 about 8 yearsI'll try this when upgrading to 16.04.1 later this year. Thanks for the tip.
-
teknopaul over 6 yearsthis had no effect for me in 2017, I think the OLD URLs in sources.list no longer work
-
Alex over 2 yearsIn Proxmox, the first command is
pct exec container-id -- bash