When mac development, docker container is not configured hosts, but the hosts mac machine configuration, the configuration of the machine hosts all containers to docker inside the container are applicable, but by linux but not when applied
The hosts can be arranged on a container of the following two methods docker
First, the time to start container plus "--add-host" configuration on the hosts
# docker run --add-host=www.baidu.com:127.0.0.1 xxx -it /bin/bash
/ Etc / hosts after the start above the container, will "www.baidu.com 127.0.0.1" is written to the configuration of the container
Into the container under verification
# docker ps -a Exec XXXX Docker # Expediting IT / bin / container id is the bash #xxx after performing the above, CONTAINER ID
# CAT / etc / the hosts
Second, start by docker-compose.yaml file
Extra_hosts configuration by the hosts to the vessel
php72: container_name: "php72" hostname: "php72" image: "xxxx" extra_hosts: - "www.baidu.com:127.0.0.1"
- "www.google.com:127.0.0.1" volumes: - xxx:xxx