Docker Community Forums

Share and learn in the Docker community.

After docker-compose restart of mongodb , data got deleted from the db

version: "2.0"
networks:
    946122fd42_net:
        external: true
services:
  node:
    container_name: middleware-node
    restart: always
    image: node:8
    volumes:
      - ./:/data/middleware
    working_dir: /data/middleware/api-server
    command: bash -c "npm install && npm run build && npm run dev"
    environment:
      - PORT=8000
    ports:
      - 0.0.0.0:8000:8000
    networks:
      - 946122fd4211_net12
    depends_on:
      - mongo
  mongo:
    container_name: mongo
    image: mongo
    volumes:
      - ./mongo/data:/data/db
    env_file:
      - .env
    ports:
      - 0.0.0.0:27017:27017
    networks:
      - 946122fd4211_net12
  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: rabbitmq
    environment:
      RABBITMQ_ERLANG_COOKIE: 'SiemensSalt'
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - 946122fd4211_net12
    depends_on:
      - node

Update: wrapped the compose file content in a code block.

By the looks of it, you did it correctly, can you see data in the ./mongo/data after restart?
just thinking if the directory gets populated at all…

Actually, MongoDB contains a lot of files and it is really difficult to find our files.
Also, when I entered the docker container,i couldn’t any collections.
any guess where it could be