Update /etc/hosts when linked container is restarted

Fix #6350


I was originally using defers in the first versions of the cli integration tests, but I've changed them.

Ideally, we'd make this part of the test teardown, so there's no need to require defering container deletion at this point.

Issue #7010 discusses changes and refactoring to be made to the cli integration tests. Perhaps that would be a better place to discuss this.