version: '3.8' services: mongodb: image: mongo:6.0 # You can change to the desired version container_name: mongodb restart: unless-stopped ports: - "27017:27017" environment: MONGO_INITDB_DATABASE: testdb # <-- This creates the initial database volumes: - mongodb_data:/data/db command: ["mongod", "--noauth"] # <-- Disable authentication volumes: mongodb_data: