Validate Names
Closed this issue · 1 comments
Due to a change in docker, container names can no longer include an underscore. A legacy name with an underscore leads to an invalid hostname (merll/docker-fabric#14) error that is hard to trace down. I suggest an assertion in the constructor for maps/containers (and/or their configs) that validates names and raises an informative exception.
Underscores are quite common for variable names in Python and in my opinion should therefore also be valid for container and client configuration names. As the restriction only seems to apply to the host names but not the Docker container names, I have added a method for replacing certain characters for container host names and link alias names. Underscores are replaced with dashes. Similarly, dots are replaced with dashes since they would lead to a strange subdomain syntax. The behavior can be customized by changing the dockermap.map.policy.base.BasePolicy.hostname_replace
dictionary.