How can you make the Docker container use the host machine's '/etc/hosts' file?

后端 未结 11 1816
夕颜
夕颜 2020-12-23 11:21

I want to make it so that the Docker container I spin up use the same /etc/hosts settings as on the host machine I run from. Is there a way to do this?

I

11条回答
  •  一个人的身影
    2020-12-23 12:04

    If you are running a virtual machine for running Docker containers, if there are hosts (VMs, etc.) you want your containers to be aware of, depending on what VM software you are using, you will have to ensure that there are entries on the host machine (hosting the VM) for whatever machines you want the containers to be able to resolve.

    This is because the VM and its containers will have the IP address of the host machine (of the VMs) in their resolv.conf file.

提交回复
热议问题