OneBite.Dev - Coding blog in a bite size

upgrade docker

Simple docker step by step how to upgrade docker with explanation

Upgrading Docker in your system ensures you are using the most up-to-date version with the latest features, security patches, and bug fixes. This simple tutorial guides you through the steps of upgrading Docker.

Prerequisites

Before starting, make sure that Docker is already installed in your system. If it’s not, you need to install Docker first.

Check Current Version

To understand what version of Docker you are running, you need to use the command line interface (CLI). Open CLI and input the following command:

docker --version

This will display the current version of Docker installed on your system.

Removing Old Version

Before installing the new Docker version, you should remove the current Docker version installed in your system. To do this, please use the following command:

sudo apt-get remove docker docker-engine docker.io containerd runc

This command will remove Docker but it will not touch your images, containers, volumes, or user-defined configuration files.

Update Package Database

The system’s package database needs to be updated. This allows it to access the latest Docker versions. To upgrade, use the following command:

sudo apt-get update    

Install Latest Docker Version

After updating the package database, you can easily install the latest Docker version. Make sure to allow your system to access the Docker repository over HTTPS. To do this, add the keys and the repository using these commands:

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
    
echo \
  "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Then, update the package database with the Docker packages from the newly added repo:

sudo apt-get update

Lastly, install Docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify Installation

The final step is to verify that the correct Docker version was installed. Use the same command from the beginning, which is:

docker --version

It should display the latest Docker version. You are now using an updated version of Docker. In conclusion, these steps ensure successful Docker upgrade for an improved container creation and management experience.

docker