From 86d053d90dd9081b43ead470ab910b021af3c9ea Mon Sep 17 00:00:00 2001 From: Alec Clews Date: Sun, 28 Jun 2020 11:02:53 +1000 Subject: [PATCH 1/2] Correct instructions for server-client networking 1. Added `--network` when starting mongo server 2. Fixed `--network` option when starting client 3. Added additional notes about use of Docker network --- mongo/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mongo/README.md b/mongo/README.md index d8f5afdbfebf..be685bbc3090 100644 --- a/mongo/README.md +++ b/mongo/README.md @@ -106,20 +106,22 @@ First developed by the software company 10gen (now MongoDB Inc.) in October 2007 ## Start a `mongo` server instance ```console -$ docker run --name some-mongo -d mongo:tag +$ docker run --name some-mongo --network=some-network-d mongo:tag ``` -... where `some-mongo` is the name you want to assign to your container and `tag` is the tag specifying the MongoDB version you want. See the list above for relevant tags. +... where `some-mongo` is the name you want to assign to your container, tag` is the tag specifying the MongoDB version you want, and `some-network` is an existing Docker network. See the list above for relevant tags. + +(Hint: A Docker network can be created with the command `docker network create some-network`) ## Connect to MongoDB from another Docker container The MongoDB server in the image listens on the standard MongoDB port, `27017`, so connecting via Docker networks will be the same as connecting to a remote `mongod`. The following example starts another MongoDB container instance and runs the `mongo` command line client against the original MongoDB container from the example above, allowing you to execute MongoDB statements against your database instance: ```console -$ docker run -it --network some-network --rm mongo mongo --host some-mongo test +$ docker run -it --network=some-network --rm mongo mongo --host some-mongo test ``` -... where `some-mongo` is the name of your original `mongo` container. +... where `some-mongo` is the name of your original `mongo` container and `some-network` is the same network used by the origonal container. ## ... via [`docker stack deploy`](https://docs.docker.com/engine/reference/commandline/stack_deploy/) or [`docker-compose`](https://github.com/docker/compose) From d8200fea60f5519a5d2db0cf451af9a3252b4973 Mon Sep 17 00:00:00 2001 From: Alec Clews Date: Wed, 16 Sep 2020 21:46:27 +1000 Subject: [PATCH 2/2] Update mongo/README.md Fix syntax Co-authored-by: Tianon Gravi --- mongo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongo/README.md b/mongo/README.md index be685bbc3090..dc1f3cbc6998 100644 --- a/mongo/README.md +++ b/mongo/README.md @@ -106,7 +106,7 @@ First developed by the software company 10gen (now MongoDB Inc.) in October 2007 ## Start a `mongo` server instance ```console -$ docker run --name some-mongo --network=some-network-d mongo:tag +$ docker run --name some-mongo --network some-network -d mongo:tag ``` ... where `some-mongo` is the name you want to assign to your container, tag` is the tag specifying the MongoDB version you want, and `some-network` is an existing Docker network. See the list above for relevant tags.