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

Correct instructions for server-client networking #1754

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down