简体   繁体   中英

Why can't I use azure file share in my docker-compose to store mongodb data in Azure Container Instance?

When using a docker ACI context, the following docker-compose file fails. The mongodb container continuously restarts.

version: "3.9"

services:
  mongodb:
    image: mongo:5.0.6
    env_file: mongo.env
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=changeit
    ports:
      - 27017
    volumes:
      - dbdata:/data/db

volumes:
  dbdata:
    driver: azure_file
    driver_opts:
      share_name: mongodb-data
      storage_account_name: kpncoqyuxumoetuftz

If I don't use the azure_file storage it will run ok (But of course the data won't be persistent)

I am not sure why I can't mount to the default directory /data/db but to get this to work I had to mount to a different directory and then replace the default command with one that takes a parameter.

Working version is below:

version: "3.9"

services:
  mongodb:
    image: mongo:5.0.6
    command: ["mongod", "--dbpath=/dbdata"]
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=changeit
    ports:
      - 27017
    volumes:
      - dbdata:/dbdata

volumes:
  dbdata:
    driver: azure_file
    driver_opts:
      share_name: mongodb-data
      storage_account_name: kpncoqyuxumoetuftz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM