How can I add hostnames to a container on the same docker network?
问题 Suppose I have a docker compose file with two containers. Both reference each other in their /etc/hosts file. Container A has a reference for container B and vice versa. And all of this happens automatically. Now I want to add one or more hostnames to B in A's hosts file. How can I go about doing this? Is there a special way I can achieve this in Docker Compose? Example: 172.0.10.166 service-b my-custom-hostname 回答1: Yes. In your compose file you can specify network aliases. services: db: