There are multiple ways to update or upgrade the docker. I prefer the following easiest way to upgrade my running docker engine. I have copied the steps from official docker documentation page. Actually, the documentation page is quite messy due to multiple options provided there
Step 1. Check the list of available docker
First we need to check what are the latest stable version of docker available. If you are unknown to what version of docker engine you are currently running. Type docker –version , which will provide you full information.
apt-cache madison docker-ce
Step 2. install the selected version
Now we have the complete list of docker versions available. Select the one you prefer and install. It’s always recommended to install the latest stable version, which contains the patches for latest vulnerabilities found.
apt-get install docker-ce=<Version> docker-ce-cli=<Version> containerd.io
Check the list and modify it to add the version required. So after adding the desired version it will be something like this:
apt-get install docker-ce=5:18.09.2~3-0~ubuntu-xenial docker-ce-cli=5:18.09.2~3-0~ubuntu-xenial containerd.io
It’s updating 3 things in one installation