Networking issues on Ubuntu 16.04

I reinstalled my machine the other day, using Ubuntu 16.04, using the official docker.io package, so using versions

Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   23cf638
 Built:        Tue, 27 Sep 2016 12:25:38 +1300
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   23cf638
 Built:        Tue, 27 Sep 2016 12:25:38 +1300
 OS/Arch:      linux/amd64

I keep on getting really strange network problems while I try to build images:

Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'

The funny thing is that

  1. my network is perfectly fine
  2. if I restart the docker daemon it works again once or twice and then it stops again, which means clearly something messed up there.

Any idea about what it could be?
Thanks

I realised that docker.io was not the right package to use and so I followed the procedure to use docker-engine instead, which gave me these versionis

Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:01:48 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:01:48 2016
 OS/Arch:      linux/amd64

I still have the same problem though it works once and maybe not the second time (until I restart the daemon), always with network issues