How do I set hostname in docker-compose?

后端 未结 8 2154
清酒与你
清酒与你 2020-11-29 18:11

In my docker-compose.yml file, I have the following. However the container does not pick up the hostname value. Any ideas?

dns:
  image: phensle         


        
相关标签:
8条回答
  • 2020-11-29 19:00

    Based on docker documentation: https://docs.docker.com/compose/compose-file/#/command

    I simply put hostname: <string> in my docker-compose file.

    E.g.:

    [...]
    
    lb01:
      hostname: at-lb01
      image: at-client-base:v1
    
    [...]
    

    and container lb01 picks up at-lb01 as hostname.

    0 讨论(0)
  • 2020-11-29 19:00

    This issue is still open here: https://github.com/docker/compose/issues/2925

    You can set hostname but it is not reachable from other containers. So it is mostly useless.

    0 讨论(0)
提交回复
热议问题