How do I set hostname in docker-compose?

后端 未结 8 2211
清酒与你
清酒与你 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 18:42

    This seems to work correctly. If I put your config into a file:

    $ cat > compose.yml <

    And then bring things up:

    $ docker-compose -f compose.yml up
    Creating tmp_dns_1...
    Attaching to tmp_dns_1
    dns_1 | 2015-04-28T17:47:45.423387 [dockerdns] table.add tmp_dns_1.docker -> 172.17.0.5
    

    And then check the hostname inside the container, everything seems to be fine:

    $ docker exec -it stack_dns_1 hostname
    affy.affy.com
    

提交回复
热议问题