jcardosovtl
jcardosovtl

Reputation: 65

Why I can't ping container by its hostname, from an external machine, while using macvlan?

I am creating a macvlan with this conf:

sudo docker network create -d macvlan \
    --subnet=192.168.4.0/24 \
    --gateway=192.168.4.1 \
    -o macvlan_mode=bridge \
    -o parent=eth0 macvlan70

Then I run an alpine image using:

docker run --net=macvlan70 --hostname=thehost --ip=192.168.4.17 -it  alpine /bin/sh

At this moment I moved to another machine in LAN - host can't connect with Macvlan containers without a bridge.

I can ping 192.168.4.17 with success. But ping thehost will not result. In the router admin page the ip 192.168.4.17 is recognized but without the hostname associated.

Upvotes: 5

Views: 1803

Answers (1)

Edwin
Edwin

Reputation: 2278

As it's said in the docker docs, the user-defined hostname is not available from outside of the container.

Even in host network mode a container has its own UTS namespace by default. As such --hostname is allowed in host network mode and will only change the hostname inside the container

Upvotes: 2

Related Questions