Docker Community Forums

Share and learn in the Docker community.

Hostname doesn't work with host networking


(Kvc4code) #1

Expected behavior

Expecting the same thing as Docker Toolbox version 1.11:
docker run --rm -it --net host debian:jessie hostname --ip-address
127.0.0.1

Actual behavior

$ docker run --rm -it --net host debian:jessie hostname --ip-address
hostname: Name or service not known

Information

OS X: version 10.11.4 (build: 15E65)
Docker.app: version v1.11.0-beta7
Running diagnostic tests:
[OK] docker-cli
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160414-150949.tar.gz
Most specific failure is: No error was detected
Your unique id is: BA7E5DF9-273C-4C58-AB5B-FE919698E609

Steps to reproduce the behavior

Stated above in “Expected behavior”


(Justin Cormack) #3

Why are you doing this exactly? I don’t think this is guaranteed to work in any setup, and the --ip-address option to hostname is marked as deprecated. Maybe can suggest a more portable method if I knew what you wanted this for.


(Kvc4code) #4

Hi Justin,
We’re using host networking for Cassandra containers and using this to set CASSANDRA_LISTEN_ADDRESS
I can see this may be problematic for a variety of reasons so if you can advise as to preferred robust mechanism for determining IP address(es) when host networking is used we will convert to that.
Thanks!