Network name could not be resolved inside the container

Hi!
For the last couple of hours I am trying to create and run a docker container for Graylog application (log collector). After successful creation I am getting the following error in the container logs:

2024-07-27 12:44:41,694 ERROR: org.graylog2.storage.versionprobe.VersionProbe - Unable to retrieve version from Elasticsearch node: Unknown host 'opensearch: Name or service not known'. - Unknown host 'opensearch: Name or service not known'.

So, to confirm that I entered the container’s bash and tried to connect to the opensearch host:

marek@d-greylog:~/graylog$ docker exec -it 908675468f49 /bin/bash
graylog@908675468f49:~$ curl -X GET http://opensearch:9200
curl: (6) Could not resolve host: opensearch
graylog@908675468f49:~$ 

I am not a docker expert, still learning, do could you please shed some light on what I am doing wrong with the docker-compose.yml file attached below? What should I do to fix the network settings to get my hostname resolved?

version: '3'
# fake passwords were used here - for docker forum
services:
  mongodb:
    image: "mongo:6.0.14"
    volumes:
      - "mongo_data:/data/db"
    restart: "on-failure"
    networks:
      - graylog

  opensearch:
    image: "opensearchproject/opensearch:2.12.0"
    volumes:
      - es_data:/usr/share/opensearch/data
    environment:
      - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      - action.auto_create_index=false
      - plugins.security.ssl.http.enabled=false
      - plugins.security.disabled=true
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=myFakeInitialAdminPassword
    ulimits:
      memlock:
        hard: -1
        soft: -1
      nofile:
        soft: 65536
        hard: 65536
    restart: "on-failure"
    networks:
      - graylog

  graylog:
    hostname: d-greylog
    image: "graylog/graylog-enterprise:6.0"
    depends_on:
      - mongodb
      - opensearch
    entrypoint: "/usr/bin/tini -- wait-for-it opensearch:9200 -t 60 -- /docker-entrypoint.sh"
    environment:
      - GRAYLOG_NODE_ID_FILE=/usr/share/graylog/data/config/node-id
      - GRAYLOG_HTTP_BIND_ADDRESS=0.0.0.0:9000
      - GRAYLOG_ELASTICSEARCH_HOSTS=http://opensearch:9200
      - GRAYLOG_MONGODB_URI=mongodb://mongodb:27017/graylog
      - GRAYLOG_REPORT_DISABLE_SANDBOX=true
      - GRAYLOG_PASSWORD_SECRET=myFakeSecretPassword
      - GRAYLOG_ROOT_PASSWORD_SHA2=786cba4c18719d24267b2c7189df8d55671454ffb30d6dba4f697c0bf39b8eec
      - GRAYLOG_HTTP_EXTERNAL_URI=http://192.168.3.3:9000/
    networks:
      - graylog
    restart: always
    ports:
      - 9000:9000
      - "5044:5044/tcp"
      - 1514:1514
      - 1514:1514/udp
      - 12201:12201
      - 12201:12201/udp
      - "13301:13301/tcp"
      - "13302:13302/tcp"
    volumes:
      - graylog_journal:/usr/share/graylog/data/journal
      - graylog_data:/usr/share/graylog/data/data

networks:
  graylog:
    external: true

volumes:
  mongo_data:
    driver: local
  es_data:
    driver: local
  graylog_journal:
    driver: local
  graylog_data:
    driver: local

Thanks in advance for your help!

A. Are you sure you need the networks?
B. Are you using other compose files with this network? If not, it does not need to be external
C. Does the network exist? Do the containers correctly connect to it?
D. Regardless of if you need the network or not, try with the network properties commented out and see what you get please

I used settings recommended by Graylog. But the issue has been resolved already. It was caused by to weak resources assigned to the LXC container on which Docker was installed (I use Proxmox server). The Opensearch container just did not have a chance to start successfully. After bumping it up to 4 GB RAM and 4 CPU cores it worked like a charm.

Thanks for looking into it!