I'm not sure the problem is with docker here. If you read the logs, it says:
It seems you are upgrading from 17.0.1 to 17.5.1.
It is required to upgrade to the latest 17.3.x version first before proceeding.
So try moving to image with any tag of 17.3.x first.