MongoDb-Kafka-Connector error

it looks like you do not have any networks defined for these, you commented out

# networks:
# - localnet

if you want all these components to be able to talk to each other they need to be on the same network so add networks: to each of the components then at the end of the docker compose file

networks:
  localnet:
    attachable: true