skip to Main Content

I am trying to launch two docker (mongodb and mongo-express) containers using separate commands, I created a network and launched the mongodb container successful.

I reconfirmed this by starting a temporal debian container on the same network and ping the mongodb server name, i was also able to telnet the server-name and port.

I however proceeded to startup the mongo-express container using the following

docker run -d --network mongo_network -p 9090:8081 -e ME_CONFIG_MONGODB_SERVER=mongo-server  -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=pass@123 --name mongo_express_console mongo-express

the container startup as expected but exits with an error within a minute, when I restart it manually it keeps exiting with a minute it was started. Checking the logs I see following

Waiting for mongo:27017...
/docker-entrypoint.sh: line 15: mongo: Try again
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Fri May 24 07:57:36 UTC 2024 retrying to connect to mongo:27017 (2/10)
/docker-entrypoint.sh: line 15: mongo: Try again
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Fri May 24 07:57:42 UTC 2024 retrying to connect to mongo:27017 (3/10)
/docker-entrypoint.sh: line 15: mongo: Try again
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Fri May 24 07:57:48 UTC 2024 retrying to connect to mongo:27017 (4/10)
/docker-entrypoint.sh: line 15: mongo: Try again
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
PS C:UsersotulanaioDocumentstestRepocompose_testingnana_tutorials> docker logs 2f335d5c78d7
Waiting for mongo:27017...
/docker-entrypoint.sh: line 15: mongo: Try again
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Fri May 24 07:57:36 UTC 2024 retrying to connect to mongo:27017 (2/10)
/docker-entrypoint.sh: line 15: mongo: Try again

I don’t know if anyone can kindly guide me to getting this resolved.

I have attempted recreating the containers severally following various tutorial and it appears it is still the same.

2

Answers


  1. The error message

    /docker-entrypoint.sh: line 15: mongo: Try again
    

    Indicates that the ME_CONFIG_MONGODB_SERVER environment variable is set correctly to mongo, which is the name of the MongoDB container.

    the var in the params that you change doesn’t change and still work with the default value.

    So try to change SERVER to :

    ME_CONFIG_MONGODB_SERVER=mongo
    

    Also, ensure that your MongoDB container is named mongo for the connection to succeed. This should resolve the connection issues with mongo-express.

    Check This issue

    Login or Signup to reply.
  2. With the latest version of mongo-express, environment variable ME_CONFIG_MONGODB_SERVER is replaced with ME_CONFIG_MONGODB_URL. Documentation on dockerhub is still old hence causing all this trouble and confusion.
    Below is the modified command

    docker run -d --network mongo_network -p 9090:8081 -e ME_CONFIG_MONGODB_URL=mongodb://admin:admin@mongo-service:27017  -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=pass@123 --name mongo_express_console mongo-express
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search