Skip to content
Open
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
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Localmongo

Local mongo replicaset running mongo:4.2-bionic for development using docker-compose.
Local mongo replicaset running mongo:4.2-bionic/4.4-bionic for development using docker-compose.

## Setup

Switch to the directory of the version you want, and run:

```
docker-compose up
docker-compose up -d
```

This should bring up 3 containers of mongodb, running a replicaset called `rs0`.
Expand All @@ -23,6 +23,8 @@ docker-compose rm

In your main application, you need to adjust your docker-compose in order for your application to be able to connect to the mongo containers. Use the below template of docker-compose.yml:

### For 4.2-bionic

```
version: "3"
services:
Expand All @@ -38,12 +40,30 @@ services:
networks:
localmongo:
external:
name: localmongo_default
name: 42_default
```
### For 4.4-bionic

```
version: "3"
services:
app:
build: .
networks:
- default
- localmongo
external_links:
- localmongo1:mongo1
- localmongo2:mongo2
- localmongo3:mongo3
networks:
localmongo:
external:
name: 44_default
```
## Troubleshooting

Assuming you clone this repo into a folder called `localmongo`, upon running docker-compose, docker will create a network called `localmongo_default`. You can view this by running `docker network ls`, and also by inspecting `docker inspect localmongo1`.
Assuming you run `docker-compose up` inside the 4.4 folder, docker will create a network called `44_default`. You can view this by running `docker network ls`, and also by inspecting `docker inspect localmongo1`.

In the application's docker-compose.yml, we are specifying that the app must join 2 networks: the `default` one, as well as `localmongo` network, which is declared at the end of the file, pointing to an external network `localmongo_default`.

Expand Down