[DependencyInjection] Allow frozen containers to be dumped to graphviz (2.1 merge)

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

This is the 2.1 merge for #7017 with an addition for 2.1 specifically.

> Note: The diff currently still contains commits from `2.0` which are not in `2.1` yet.