Downgrading a package in Ubuntu

A recent regression badly broke the docker compose plugin. A comment in that issue indicated it probably wouldn’t be fixed until after the holidays, so I needed to roll back to a previous working version.

I’ve never actually had to do that with a package before. It was pretty easy, though the steps are not immediately apparent. Here’s what I did, maybe it will help someone trying to accomplish something similar.

I’m using the repository for Docker Engine. You can load the repository URL in a browser to navigate around: https://download.docker.com/linux/ubuntu/

Find the exact version string to tell apt to install. For third party repositories, the string will often include the distro and version in it. I’m running Ubuntu 22.04 (jammy) so I downloaded this text file containing the released versions for my distro, version, and architecture:
https://download.docker.com/linux/ubuntu/dists/jammy/stable/binary-amd64/Packages

Looking through that file, it’s evident that the last version released prior to 2.32.0 for the docker-compose-plugin package was “2.31.0-1~ubuntu.22.04~jammy”.

Run this command to install that version:

apt install docker-compose-plugin=2.31.0-1~ubuntu.22.04~jammy

Now apt needs to be told not to try to upgrade docker-compose-plugin the next time you run “apt upgrade”:

apt-mark hold docker-compose-plugin

When a new package is released with the fix, replace “hold” with “unhold” in the above command to allow the upgrade.

Leave a Reply

Your email address will not be published. Required fields are marked *