📜  docker compose 定义容器主机名 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:49.545000             🧑  作者: Mango

代码示例1
$ cat docker-compose.yml
version: '3'
services:
  nginx-1:
    image: nginx
    hostname: nginx-1.docker
    network_mode: bridge 
  linux-1:
    image: alpine
    hostname: linux-1.docker
    command: sh -c 'apk add --update bind-tools && tail -f /dev/null'
    network_mode: bridge # that way he can solve others containers names even inside, solve nginx-2, for example