Using --add-host or extra_hosts with docker-compose

后端 未结 5 2052
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 03:47

I am using docker-compose to run a test environment, that consists of about 5 different containers. The inter-container links and the shared volumes (volumes-from)

5条回答
  •  隐瞒了意图╮
    2021-01-30 04:20

    https://docs.docker.com/compose/compose-file/#extra_hosts

    extra_hosts - Add hostname mappings. Uses the same values as the docker client --add-host parameter.

    extra_hosts:
     - "somehost:162.242.195.82"
     - "otherhost:50.31.209.229"
    

    An entry with the ip address and hostname will be created in /etc/hosts > inside containers for this service, e.g:

    162.242.195.82  somehost
    50.31.209.229   otherhost
    

提交回复
热议问题