How link mongo container with existing nodejs container

Expected behavior

Nodejs container should access the mongodb container

Actual behavior

Not able to connect with existing nodejs container

Additional Information

Steps to reproduce the behavior

The best practice way would be to write a docker-compose.yml and respawn both containers. Inside the compose file you can specify that both have a 2nd network that connects both containers.

The ugly but works for now (it is really fragile and will break if you respawn or update the container) way is to add a network interface to both containers and docker exec into both to configure it.

If using docker-compose does not fit your purpose (like having to link having to allow a multi container or docker-compose based deployment to access one more container) you may go for using ansible/chef/slat and add the network interface there. That way you don’t have to modify the existing docker-compose, but also don’t require manual thinkering that is very likely to break.

1 Like

Thanks agowa338 for suggesting the way. It would be very helpful if you can share any link for reference.

Regards,

What do you mean by sharing a reference? A link to the documentation of docker-compose?



1 Like