I have just done a do-release-upgrade -m server from

Linux 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 returns 4.2.0-16-generic which confirms that the kernel is on Wily, doing an apt-get update shows that the container is still pointed at the Vivid repository.

do-release-upgrade while attached to the container returns bash: 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)

share|improve this question

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.

share|improve this answer
    
I'll try this when upgrading to 16.04.1 later this year. Thanks for the tip. – Mausy5043 May 7 '16 at 16:54

Here's what seems to have worked for me:

$ sudo lxc-attach --name <container>

Then edit /etc/apt/sources.list and replace all occurences of vivid to wily.

Next do:

# apt-get update
# apt-get upgrade
# apt-get dist-upgrade
# apt-get autoclean
# apt-get autoremove
# reboot

Repeat this a couple of times until all packages are updated.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.