Switch to using hyphens as a separator in hostnames
Problem
The hostname format used by fig creates names that are not strictly valid. Current pseudo-code: [code block] This generates names like `cluster_hadoop_1`. Underscores are not valid (though in practice _most_ components are tolerant of this). Valid names should match `[a-zA-Z0-9\-]+`. I came across this error when trying to test out some hadoop/hdfs containers and hadoop bailed with an exception saying that `hdfs://flume_hadoop_1/` was not valid URI (even though it was in `/etc/hosts` and `ping flume_hadoop_1` worked just fine). See: http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names Changing this to dashes is easy, but it would break existing configurations that depend on hard coded container names.
Error Output
error when trying to test out some hadoop/hdfs containers and hadoop bailed with an exception saying that `hdfs://flume_hadoop_1/` was not valid URI (even though it was in `/etc/hosts` and `ping flume_hadoo
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Switch to using hyphens as a separator in hostnames
Frustratingly, underscores are invalid in hostnames, and dashes are invalid in shell variable names. So if you can't name a Docker link without either breaking one of those or smushing everything together (e.g. `hadoop1`). Not ideal. However, looks like https://github.com/docker/docker/pull/6270 might fix this by sanitising environment variable names, in which case Fig can switch to dashes and ev
Trust Score
2 verifications
- 1
Frustratingly, underscores are invalid in hostnames, and dashes are invalid in s
Frustratingly, underscores are invalid in hostnames, and dashes are invalid in shell variable names. So if you can't name a Docker link without either breaking one of those or smushing everything together (e.g. `hadoop1`). Not ideal.
text``` bash $ fig run web cat /etc/hosts ... 172.17.0.42 hadoop-1 ... $ fig run web env ... HADOOP_1_PORT=tcp://172.17.0.42:5432 HADOOP_1_PORT_5432_TCP=tcp://172.17.0.42:5432 HADOOP_1_PORT_5432_TCP_ADDR=172.17.0.42 ... - 2
However, looks like https://github.com/docker/docker/pull/6270 might fix this by
However, looks like https://github.com/docker/docker/pull/6270 might fix this by sanitising environment variable names, in which case Fig can switch to dashes and everything will hopefully work:
Validation
Resolved in docker/compose GitHub issue #229. Community reactions: 1 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep