Accessing container with name in custom bridge network

  docker, docker-network, docker-networking

I created custom bridge network as:

docker network create test

I am running Mongo DB image in this network with following command:

docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=test -e MONGO_INITDB_ROOT_PASSWORD=password --name=testdb mongo
This created container and I'm able to connect to this from robo3T.

Now I ran mongo-express image in same network with following command and trying to above DB:

docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=test -e ME_CONFIG_MONGODB_ADMINPASSWORD=password -e ME_CONFIG_MONGODB_SERVER=testdb --name=mongo-ex mongo-express

But I’m getting following error:

UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [testb:27017] on first connect [Error: getaddrinfo ENOTFOUND testdb

Can someone help me with this please?

Source: Docker Questions