Windows中Rabbitmq Docker容器的正确路径

时间:2019-10-22 20:13:56

标签: windows docker docker-compose rabbitmq

我在docker-compose.yml文件中有一个RabbitMQ Docker容器。

  rabbit:
    image: rabbitmq:3-management
    ports:
      - "15672:15672"
      - "5672:5672"
      - "61613:61613"
      - "15674:15674"
    volumes:
      - ./enabled_plugins:/etc/rabbitmq/enabled_plugins
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=default"
      - "traefik.ws.port=15674"
      - "traefik.ws.frontend.rule=PathPrefixStrip:/stomp/"
      - "traefik.web.port=15672"
      - "traefik.web.frontend.rule=PathPrefixStrip:/rabbit/"

问题是当我执行docker-compose up -d时,出现错误。

$ docker-compose up -d
Removing deploji-server_rabbit_1
deploji-server_postgres_1 is up-to-date
Starting 820ca92c591a_deploji-server_server_1 ...
Recreating 563cd247aa16_deploji-server_rabbit_1 ...
deploji-server_traefik_1 is up-to-date
Recreating 563cd247aa16_deploji-server_rabbit_1 ... error
Starting 98268bf1b8a7_deploji-server_worker_1   ... done

ERROR: for 563cd247aa16_deploji-server_rabbit_1  Cannot start service rabbit: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Projects/deploji-server/enabled_plugins\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56aStarting 820ca92c591a_deploji-server_server_1   ... done
tmq/enabled_plugins\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

ERROR: for rabbit  Cannot start service rabbit: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Projects/deploji-server/enabled_plugins\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56a/merged\\\" at \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56a/merged/etc/rabbitmq/enabled_plugins\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Encountered errors while bringing up the project.

在Linux环境中,似乎只有Windows才没有问题。我认为enabled_plugins文件的路径不正确。我尝试将映射更改为类似

  • ./ enabled_plugins:/ c / rabbitmq

并且容器似乎已启动,但是服务器没有响应,所以我猜想enabled_plugins文件中的插件未正确安装。

可以在此处看到整个docker-compose.yml文件:https://github.com/maxmeister/deploji-server/blob/master/docker-compose.yml

有关如何使其在Windows计算机上正常运行的任何建议?预先感谢。

1 个答案:

答案 0 :(得分:0)

我建议遵循docs: 如果使用短语法,则有几种选择:

  

SHORT SYNTAX(可选)在主机上指定路径   (HOST:CONTAINER)或访问模式(HOST:CONTAINER:ro)。

     

您可以在主机上安装相对路径,该路径相对于   使用的Compose配置文件的目录。相对的   路径应始终以开头。或...

volumes:
  # Just specify a path and let the Engine create a volume
  - /var/lib/mysql

  # Specify an absolute path mapping
  - /opt/data:/var/lib/mysql

  # Path on the host, relative to the Compose file
  - ./cache:/tmp/cache

  # User-relative path
  - ~/configs:/etc/configs/:ro

  # Named volume
  - datavolume:/var/lib/mysql

相关的question和答案