How to get the hostname of the docker host from inside a docker container on that host without env vars

后端 未结 8 1389
时光取名叫无心
时光取名叫无心 2020-12-13 12:13

What are the ways get the docker host\'s hostname from inside a container running on that host besides using environment variables? I know I can pass the hostname as

8条回答
  •  青春惊慌失措
    2020-12-13 12:59

    Another option that worked for me was to bind the network namespace of the host to the docker.

    By adding:

    docker run --net host
    

提交回复
热议问题