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

hostname in /etc/hosts disappears when --publish option is used for a service in Docker Swarm #36575

Open
fabrizio2210 opened this issue Mar 13, 2018 · 0 comments

Comments

@fabrizio2210
Copy link

fabrizio2210 commented Mar 13, 2018

Description
When I deploy an image as a service in a Docker Swarm environment, the /etc/hosts of the container is populated in different manner. I found that the hostname of the container is not added when I use --publish PORT option.

I build this image to test: fabrizio2210/test-hostname:latest
This is is the Dockerfile:

FROM arm32v7/busybox
COPY script.sh  script.sh
CMD [ "./script.sh"]

And this is the content of the script.sh:

#!/bin/sh

cat /etc/hosts 
while true; do
sleep 5
done

Steps to reproduce the issue:

  1. Deploy the service using this command:
    docker service create --name test fabrizio2210/test-hostname:latest
  2. Check output of the container or enter in the container to "cat" the /etc/hosts
    You can see the couple IP of the container and hostname like:
    172.17.0.2 a3108c5bfefb
  3. Deploy the same service with the published port:
    docker service create --name test --publish 80 fabrizio2210/test-hostname:latest
  4. Check output of the container or enter in the container to "cat" the /etc/hosts
    There is no hostname in /etc/hosts except for localhost

Describe the results you received:

pi@raspberrypi0:~ $ docker container logs cf0c51d01a9b
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Describe the results you expected:

pi@raspberrypi0:~ $ docker container logs a3108c5bfefb
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2      a3108c5bfefb

Additional information you deem important (e.g. issue happens only occasionally):
The issue always happens

Output of docker version:

pi@raspberrypi0:~ $ docker version
Client:
 Version:       17.12.1-ce
 API version:   1.35
 Go version:    go1.9.4
 Git commit:    7390fc6
 Built: Tue Feb 27 22:25:15 2018
 OS/Arch:       linux/arm

Server:
 Engine:
  Version:      17.12.1-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   7390fc6
  Built:        Tue Feb 27 22:21:21 2018
  OS/Arch:      linux/arm
  Experimental: false

Output of docker info:

pi@raspberrypi0:~ $ docker info
Containers: 20
 Running: 3
 Paused: 0
 Stopped: 17
Images: 68
Server Version: 17.12.1-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: y15gvi6g5o50zu2q3qzo2eq6c
 Is Manager: true
 ClusterID: kx4saemliu20kljbbxb4kh1pq
 Managers: 2
 Nodes: 2
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 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.4.10
 Manager Addresses:
  192.168.4.10:2377
  192.168.4.11:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9b55aab90508bd389d7654c4baf173a981477d55
runc version: 9f9c96235cc97674e935002fc3d78361b696a69e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.59-v7+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 927.3MiB
Name: raspberrypi0.oss
ID: OKJL:ZBK7:WL6R:EDZN:25NF:JK5X:KPPP:7SKK:O4LQ:CVKK:SKID:6INB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: fabrizio2210
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

Additional environment details (AWS, VirtualBox, physical, etc.):
The environment is on raspberry pi 3

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

2 participants