Skip to content

Change the user or permission of db in container #282

Description

@jimmylin212

Is it possible to change the user name from mongodb to other user in the container?

I would like to mount the directory SOME_PATH_ON_HOST into container and the user of this directory is USER. When the service started, it shows permission error. Can I change the user or permission of /data/db in container to USER instead of create a mock user mongodb on the host?

I am using docker stack to deploy my services. Kindly see my docker-compose.yml below:

version: '3.2'
services:
  db:
    image: mongo
    volumes:
      - "SOME_PATH_ON_HOST:/data/db"
    environment:
      - MONGO_INITDB_DATABASE=example_db
    deploy:
      replicas: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions