YoavKlein
YoavKlein

Reputation: 2705

What is the --domainname option used for in Docker?

I've been searching the web back and forth and just couldn't find something informative enough about the --domainname in docker run

What is the meaning of it? What effect does it have?

I'm trying to run this docker-compose.yaml file:

version: "3.9"
services:
  server:
    domainname: myexample.com
    hostname: myserver
    image: "net-utils:0.3"
    command: ["tail", "-f", "/dev/null"]
  client:
    domainname: myexample.com
    hostname: myclient
    image: "net-utils:0.3"
    command: ["tail", "-f", "/dev/null"]

And now from within the container:

root@myclient:/# ping myserver.myexample.com
ping: myserver.myexample.com: No address associated with hostname
root@myclient:/# ping server.myexample.com
ping: server.myexample.com: No address associated with hostname

So what is the use of it?

Upvotes: 1

Views: 3546

Answers (1)

larsks
larsks

Reputation: 312370

The --domainname option has nothing to do with DNS or hostnames. From the docker run man page:

       --domainname=""
          Container NIS domain name

       Sets the container's NIS domain name (see also setdomainname(2)) that is
          available inside the container.

It sets the NIS domainname, which is only relevant if you're using NIS, which these days isn't all that likely.

Upvotes: 2

Related Questions