Запуск mongodb в контейнере
path-to-dir – путь к папке, где будет лежать база и файлы docker-compose.yml и .env для запуска$ cd /path-to-dir $ mkdir -p mongo-db/db/ $ cat docker-compose.yml version: '2.4' services: mongo-db27001: image: "mongo:5.0.3" user: "1000:1000" container_name: mongo-db27001 # Вкл авторизацию: command: [--auth] # command: [--auth] volumes: - ./mongo-db/db:/data/db restart: on-failure cpus: 5 mem_limit: 10gb ports: - "27001:27017" healthcheck: test: echo 'db.stats().ok' | mongo localhost:27017/just4testNur --quiet interval: 5s timeout: 5s retries: 12 networks: default: external: name: agis-net $ cat .env COMPOSE_PROJECT_NAME=mongo-db27001 $ docker-compose up -d Creating mongo-db27001 ... done $ docker-compose ps -a Name Command State Ports ------------------------------------------------------------------------------------------------------------------ mongo-db27001 docker-entrypoint.sh mongod Up (health: starting) 0.0.0.0:27001->27017/tcp,:::27001->27017/tcp $ docker-compose down -v Stopping mongo-db27001 ... done Removing mongo-db27001 ... done Network agis-net is external, skipping$ cat agis-db.yml version: ‘2.4’ services: agis-mongo-db: image: “mongo:4.4” container_name: agis-mongo-db #command: mongod –noprealloc –smallfiles –replSet mongors2 –dbpath /data/db –nojournal –oplogSize 16 –noauth # command: mongod –auth