Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better example in Read Me for "Connect to MongoDB from another Docker container" #336

Closed
snoblenet opened this issue Feb 13, 2019 · 3 comments

Comments

@snoblenet
Copy link

At https://hub.docker.com/_/mongo/, under "Connect to MongoDB from another Docker container", the example given is if you want to run two MongoDB containers side-by-side, but you want to connect them so you only have to start the Mongo server in one of them. This makes for some very confusing language, with mongo-this and mongo-that spread over two lines. It's impossible to unpack host name from link name from tag name from service name across two run commands.

Would it be possible to replace this example with a more useful one please? The perfect example would be this: Mongo is running one container, your web server is running in another, and the web server needs to access Mongo.

Many thanks.

@tianon
Copy link
Member

tianon commented Feb 13, 2019

$ docker network create some-network
$ docker run -d --name some-mongo --network some-network mongo:X.Y
$ docker run -d --name some-website --network some-network -e SOME_WEBSITE_MONGO=mongodb://some-mongo some-website-image

(Quite a bit more verbose and IMO not really any more clear.)

There's also a stack.yml example that I think is somewhat more clear: https://hub.docker.com/_/mongo#-via-docker-stack-deploy-or-docker-compose

@snoblenet
Copy link
Author

Thanks. This worked for me:

$ docker network create skynet
$ docker run -d --name mongo --network skynet mongo:3.4.19
$ docker run -it --net skynet -e MONGO_HOST=mongo samsao/mongo-shell:3.4

@tianon
Copy link
Member

tianon commented Mar 19, 2019

Adjusted via docker-library/docs#1441 👍

@tianon tianon closed this as completed Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants