Hello guys,
I have one problem and maybe misunderstanding with docker images.
I need to run two separate mongodb 3.6 containers for my two different projects. But it seems that if use same image (mongo:3.6), then containers will use the same data, configurations, etc…
I use docker-compose to run and manage my containers. My docker-compose.yml looks like this:
services:
first-mongo:
image: mongo:3.6
container_name: first-mongo
mem_limit: 4g
restart: always
ports:
- '27017:27017'
volumes:
- ${FIRST_MONGO_DB_LOCAL_PATH}:/data/db
- ${FIRST_MONGO_DB_LOCAL_DUMP_PATH}:/data/dumps
- ${FIRST_MONGO_DB_LOCAL_SCRIPTS_PATH}:/data/scripts
second-mongo:
image: mongo:3.6
container_name: second-mongo
mem_limit: 4g
restart: always
ports:
- '27018:27018'
volumes:
- ${SECOND_MONGO_DB_LOCAL_PATH}:/data/db
- ${SECOND_MONGO_DB_LOCAL_DUMP_PATH}:/data/dumps
- ${SECOND_MONGO_DB_LOCAL_SCRIPTS_PATH}:/data/scripts
So, having this configuration my two containers run okay. However, when I took second container’s ip address and tried to connect to database I saw the same data as in first container. Also, when I change something, the changes appear in both containers/images. Locally, I have different data in the first and second containers.
I would greatly appreciate any help. Thank you!