Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service which is deployed as part of a stack has an illegal character in its DNS name #37632

Open
raehalme opened this issue Aug 14, 2018 · 6 comments

Comments

@raehalme
Copy link

Description

When a service is created as part of a stack it is given a DNS name in the form of <stack>_<service>. According to RFC-952 a host or domain name is "a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.)." (The maximum length has since been extended in RFC-1123.)

The underscore (_) is problematic since it does not adhere to the specification. Parsers which are strict about the characters, for example the one in class java.net.URI as part of the Java programming language runtime, fail to parse the DNS name.

Please consider changing the scheme how a DNS name is defined for a service. Natural alternative to the underscore would be the minus sign (-).

Steps to reproduce the issue:

  1. Create a Docker Swarm cluster (one node is just fine)
  2. Define a stack in mystack.yml:
version: "3.7"
services:
    web1:
        image: nginx:1.15.2-alpine
    web2:
        image: nginx:1.15.2-alpine
  1. Deploy the stack:
$ docker stack deploy -c mystack.yml mystack 
Creating network mystack_default
Creating service mystack_web1
Creating service mystack_web2
  1. Start a shell in one of the services to test DNS resolution:
$ docker exec -it mystack_web2.1.dt5397y6vnli94das0hcx0dpl /bin/sh
/ # ping -c 1 web1
PING web1 (10.0.2.3): 56 data bytes
64 bytes from 10.0.2.3: seq=0 ttl=64 time=0.209 ms
--- web1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.209/0.209/0.209 ms
/ # ping -c 1 mystack_web1
PING mystack_web1 (10.0.2.3): 56 data bytes
64 bytes from 10.0.2.3: seq=0 ttl=64 time=0.106 ms
--- mystack_web1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.106/0.106/0.106 ms
/ #

Describe the results you received:
Services have names mystack_web1 and mystack_web2.

Describe the results you expected:
I was expecting the names to be RFC compliant, for example mystack-web1 and mystack-web2.

Output of docker version:

$ docker version
Client:
 Version:           18.06.0-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        0ffa825
 Built:             Wed Jul 18 19:11:45 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.0-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       0ffa825
  Built:            Wed Jul 18 19:14:07 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

$ docker info
Containers: 2
 Running: 2
 Paused: 0
 Stopped: 0
Images: 1
Server Version: 18.06.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: u8szumvio8wwdp91snhxdqojp
 Is Manager: true
 ClusterID: q1tglh4mcfakg9z09vc4ej57v
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 10
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.86.32
 Manager Addresses:
  192.168.86.32:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.17.11-200.fc28.x86_64
Operating System: Fedora 28 (Workstation Edition)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.36GiB
Name: cc1407a
ID: U7OW:ZSAP:EKNU:IZAV:P7VK:EWPG:IUUE:LLZ5:ONZR:3F25:JT3H:P5PX
Docker Root Dir: /data/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: xxx
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
@lindsve
Copy link

lindsve commented Oct 2, 2018

Just ran into this issue now. The newer versions of the Java InfluxDb client library has changed to use java.net.URI to parse host addresses, which fails within our docker swarm environment.

@sandys
Copy link

sandys commented Aug 10, 2019

we are facing this exact issue in deploying dgraph as well. a lot of go libraries refuse to parse underscore in hostnames.

@oppokui
Copy link

oppokui commented Oct 23, 2019

Any update? Can't imagine Docker has such problem and no fix immediately.

@cpuguy83
Copy link
Member

cpuguy83 commented Nov 5, 2019

@arkodg PTAL

@arkodg
Copy link
Contributor

arkodg commented Nov 5, 2019

changing the format now will disrupt legacy systems
A workaround is to add ALIASES for the service in the compose file that does not use _ and circumvents the library check
https://docs.docker.com/compose/compose-file/ has some examples for aliases

@dmolesUC
Copy link

dmolesUC commented Nov 12, 2020

I understand the backwards compatibility issue, but a flag or configuration option to let users opt into generating RFC 921–compatible DNS names (“must start with a letter, end with a letter or digit and have only letters or digits or hyphen as interior characters”) would nonetheless be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants