Consistent hosts

This patch makes `/etc/hosts` file records consistent between container restarts.
Fixes #8972 
Well I would say if we didn't want to implement that they we should probably just return an error and not `(int, error)` because 99% of the time the user will just discard that len written and there is not much to do with it