I have ran into a need for a specific version of Docker on occasion (looking at you Rancher and Kubernetes) and the debian repos contain a non-supported version for Rancher to use in particular.
First, lets uninstall the existing versions you may have.
sudo apt-get purge docker-engine
And then, this will install version 1.12 (replace version in URL as needed) of Docker.
curl -s https://releases.rancher.com/install-docker/1.12.sh|sh
This will hold it from updates (apt pinning)
sudo apt-mark hold docker-engine
There you go, simple and easy.