Why is recomended way to mount rabbitmq.conf and definitions.json from docker-compose to host machine when using rabbitmq official image

Issue

This Content is from Stack Overflow. Question asked by marissa

I have created docker-compose file that should start rabbitmq.

version: "2.2"
services:
  rabbitmq:
    image: "rabbitmq:<version>-alpine"
    hostname: "rabbitmq"
    container_name: "rabbitmq"
    mem_limit: "750m"
    ports:
    ...
    networks: [ "traefik" ]
    labels:
     ...
    volumes:
      - "./rabbitmq.conf:/etc/rabbitmq/conf.d/rabbitmq.conf:ro"
      - "./definitions.json:/etc/rabbitmq/definitions.json:ro"
      - "/setlog/rabbitmq/data:/var/lib/rabbitmq/mnesia" # data dir
    healthcheck:
      test: "rabbitmq-diagnostics -q check_running"
      interval: "20s"
      timeout: "7s"
      retries: 2
    restart: "always"

networks:
  traefik:
    external: true

My issue is that user of files inside of docker container is “rabbitmq” and when I do mount of this files from host machine to container as it is shown in code above, this files get new user and owner.

Can I somehow make that user outside of docker files is user “a” and that user inside of docker-container stays to be “rabbitmq” user?

Is there a way to check if it is important that user of this files is “rabbitmq” inside of docker container or not, I could not find anything in official rabbitmq docker image documentation ?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?