How to prevent Linux Ubuntu auto-updating programs

Often in production environments you only want to run a certain version or release of applications until you have had a chance to test new versions for issues. Once these new updates have been tested they can then be deployed to your production environments.

Some package managers such as apt (advanced package tool) will auto-update applications installed such as docker. In cases that this behaviour is unwanted how do we stop the package manager installing new versions?

apt-mark hold

The above command “apt-mark hold” is the command we want to run to stop packages auto-updating. In our demo we are going to run the command to stop Docker updating to a newer version without our knowledge.

sudo apt-mark hold docker-ce

You’ll receive a confirmation message that the package is now on hold and updates will no longer be installed.

If you forget which packages you have held you can run the below to show your current list of held packages:

apt-mark showhold

When we’re ready to install updates again for that package we need to run the below command:

sudo apt-mark unhold docker-ce

Then we can install the updates using “sudo apt-get update” as normal.

Leave a Reply

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