Docker Community Forums

Share and learn in the Docker community.

Not Able to Access the Mongodb from SpringBootApplication image inside the docker

dockerhub

(Sourabhblock) #1

Hi Team,

I have tried many option to access the mongodb image from docker.It works fine outside the docker but If I run the application in docker container it shows me error.Mention below are screenshot of error.Also share you the code of connection and commands which I am running.
Exception while running spring boot application

Mongo Db Container Running

Java Code used for connect to docker mongodb image
MongoClient mongo = new MongoClient(new ServerAddress(“0.0.0.0”, 27017));

Command Tried
docker run testingsprint
docker run testingsprint --link mongo
docker run demo --name springboot-mongo --link=“mongo” springboot-mongo

Kindly provide me the solution.

Thank you
Sourabh Lodha