I would like to ask docker-compose after establishing links, what is the reason for not creating a reference in / etc/hosts?

docker-compose.yml

version: "2"
services:
  api:
    build: .
    links:
      - mongo:mongo
    ports:
      - 9527:9527
    restart: unless-stopped
    volumes:
      - $PWD:/usr/src/app/
    env_file:
      - .env
    environment:
      - MONGO_HOST=mongodb://mongo/api
    hostname: api
    depends_on:
      - mongo
  mongo:
    image: bitnami/mongodb:latest
    hostname: mongo
    restart: unless-stopped
    ports:
      - 27017:27017

/ etc/hosts of the api container

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.3      api

/ etc/hosts of the mongo container

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.2      mongo
There is no problem with

creation, but as far as I understand it, you should create an alias in api container / etc/hosts . The result is no, just create the container"s own

.
Apr.07,2021

has been solved, just use it directly

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36631-e55c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36631-e55c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?