The following commands are used in a maintenance script in order to upgrade packages on the Ubuntu system:

dpkg --configure -a
DEBIAN_FRONTEND=noninteractive apt upgrade -yq -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef"

The issue is that upgrading Docker (e.g. 20.10.15 -> 20.10.16) deletes all images and containers. It's effectively a clean installation of the new version. This is a problem, since Rancher integration relies on containers.

How can I upgrade Docker, so that images and containers survive?

Ubuntu 18.04.6 LTS | docker-ce/bionic,now 5:20.10.16~3-0~ubuntu-bionic amd64 [installed]

  • You are not using Docker package provided by Debian but most probably by upstream. Debian's own packaged Docker is package docker.io and has stable version 20.10.5+dfsg1-1+deb11u1 and testing/usntable is version 20.10.14+dfsg1-1 . So I guess you are referring to upstream packaged docker-ce instead. This does matter when talking about a packaged Docker, because packaging and upgrade management can be quite different.
    – A.B
    May 20 at 14:00
  • 1
    Note: docker.io had no issue with upgrades, but at the same time there are rarely upgrades (last was in December 2021 for some backported security fixes). And also there is a dedicated Debian package for managing upgrades: unattended-upgrades.
    – A.B
    May 20 at 14:05
  • @A.B - The OS is Ubuntu, so not Debian in this case. Who is the “upstream” providing docker-ce? Do you know whether there are problems upgrading this package?
    – Shuzheng
    May 22 at 17:32
  • Is there a way to customise the upgrade, so data persist between releases?
    – Shuzheng
    May 22 at 17:34
  • 1
    @Shuzheng apt-cache policy docker-ce should tell you which repos it's available from
    – muru
    May 23 at 10:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.