windows 如何使用docker容器在浏览器中打开rabbitmq?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47290108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:59:26  来源:igfitidea点击:

How to open rabbitmq in browser using docker container?

windowsdockerrabbitmq

提问by Olegs Jasjko

This was probably asked already, but so far I can't find any detailed explanation at all, and the existing documentation seems as if it was written for some kind on psychic who supposed to know everything.

这可能已经被问到了,但到目前为止我根本找不到任何详细的解释,而且现有的文档似乎是为某种应该知道一切的通灵者写的。

As per this manual, I added the container

根据本手册,我添加了容器

docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:latest

Then I checked it to receive the container ip

然后我检查它以接收容器ip

docker inspect some-rabbit

Checked ports with

检查端口

docker ps

And tried to connect in the browser with this formula

并尝试使用此公式在浏览器中进行连接

https://{container-ip}:{port}

It did't work.

它没有用。

Am I'm doing something wrong, or maybe I am supposed to add something additional, like a container for apache or other stuff?

我做错了什么,或者我应该添加一些额外的东西,比如 apache 或其他东西的容器?

EDIT

编辑

As I understand, after creating some-rabbit container, now I need to run Dockerfile to create image? (This whole thing is confusing to me). How am I supposed to do that? I mean, I saw command docker build -f /path/to/a/Dockerfilebut if for example I placed the Dockerfile in second path D:\Docker\rabbitmq, how I supposed to get there? (the path doesn't seems to be recognized)

据我了解,在创建 some-rabbit 容器后,现在我需要运行 Dockerfile 来创建图像吗?(这整件事让我感到困惑)。我该怎么做?我的意思是,我看到了命令,docker build -f /path/to/a/Dockerfile但是例如,如果我将 Dockerfile 放在第二个路径中D:\Docker\rabbitmq,我应该如何到达那里?(似乎无法识别路径)

回答by yamenk

You are using the wrong image which doesn't have the rabbitmq_management plugin enabled. Change rabbitmq:latestto rabbitmq:management.

您使用了错误的图像,该图像没有启用 rabbitmq_management 插件。更改rabbitmq:latestrabbitmq:management

On dockerhubthey are using the command:

dockerhub 上,他们使用以下命令:

docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3-management

If you want to go to the UI on localhost:15672make sure to expose the port by adding -p 15672:15672to the above command.

如果您想转到 UI,请localhost:15672确保通过添加-p 15672:15672到上述命令来公开端口。

The management image is just the rabbitmq lattest image with the management plugin enabled. Here is the dockerfile for rabbitmq:management

管理镜像只是启用了管理插件的 rabbitmq 最新镜像。这是 dockerfilerabbitmq:management

FROM rabbitmq

RUN rabbitmq-plugins enable --offline rabbitmq_management

EXPOSE 15671 15672

回答by twoTimesAgnew

First off, you need the management image (eg. rabbitmq:3-management) to access it through the browser. If your docker is running locally, then you should be able to access it by navigating to http://localhost:{port}or http://127.0.0.1:{port}(15672by default).

首先,您需要管理图像(例如rabbitmq:3-management)才能通过浏览器访问它。如果您的 docker 在本地运行,那么您应该能够通过导航到http://localhost:{port}http://127.0.0.1:{port}15672默认情况下)来访问它。

Here is an example of a simple docker-compose.yml:

这是一个简单的示例docker-compose.yml

version: "3"
services:
 rabbitmq:
    image: "rabbitmq:3-management"
    ports:
      - "5672:5672"
      - "15672:15672"
    volumes:
      - 'rabbitmq_data:/data'

volumes:
  rabbitmq_data:

After starting the container, Rabbitmq is now accessible at http://127.0.0.1:15672. The default username and password should be guest:guest. More details here.

启动容器后,Rabbitmq 现在可以在http://127.0.0.1:15672. 默认用户名和密码应该是guest:guest. 更多细节在这里

enter image description here

在此处输入图片说明

回答by Isuru Amarathunga

Better to expose all three ports (5672, 5673, 15672).

最好公开所有三个端口(5672、5673、15672)。

docker run -d --name some-rabbit -p 5672:5672 -p 5673:5673 -p 15672:15672 rabbitmq:3-management  

Then you may browse, http://localhost:15672/with the credentials "guest" for both the username and the password.

然后,您可以使用用户名和密码的凭据“guest”浏览http://localhost:15672/

回答by Rashad Farajullayev

if you launched rabbitmq by using somthing like:

如果您使用以下内容启动rabbitmq:

docker run -d --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq

then you can enable its management plugins while that container runs using the following command:

然后您可以在容器运行时使用以下命令启用其管理插件:

docker container exec -it some-rabbit rabbitmq-plugins enable rabbitmq_management

and the management GUI is running on http://localhost:15672For management GUI

并且管理 GUI 在http://localhost:15672 上运行用于管理 GUI

username: guest

用户名: guest

password: guest

密码: guest

回答by Gon?alo

The compose would be like

撰写会像

version: '3'
services:
  rabbitmq:
    image: rabbitmq:management
    ports:
      - '5672:5672'
      - '15672:15672'
    volumes:
      - rabbitmq_data

回答by alif

Instead of http://localhost:15672you would want to use the ip that your docker instance is running on. On windows run:

而不是http://localhost:15672你会想要使用你的docker实例正在运行的 ip。在 Windows 上运行:

ipconfig

Use the ip address as highlighted below: enter image description here

使用下面突出显示的 IP 地址: 在此处输入图片说明

Then try http://10.0.75.1:{your-rabbitmq-port}

然后尝试http://10.0.75.1:{your-rabbitmq-port}

回答by Ivandro Ismael Gomes Jao

I see some useful answer, but none as mentioned how to access the server (rabbitmq) using container's ip-address. For people looking for this solution...

我看到了一些有用的答案,但没有提到如何使用容器的 ip 地址访问服务器(rabbitmq)。对于寻求此解决方案的人...

  • Make sure you have your rabbitmq image running on a container run: docker inspect
  • [container-id] and scroll down to find the container's ip-address.
  • add routing to contain's ip-address see `<
  • 确保您的 rabbitmq 映像在容器运行中运行: docker inspect
  • [container-id] 并向下滚动以查找容器的 IP 地址。
  • 添加路由以包含的 ip-address 见 `<

: github-issues

: github 问题

回答by RefaelJan

In my case I could access the UI of RabbitMQ for several days but some day it suddenly stop working and I can't access it anymore.

就我而言,我可以访问 RabbitMQ 的 UI 几天,但有一天它突然停止工作,我无法再访问它。

After some investigation the source of this problem was found. It was the main service of docker that somehow stopped.

经过一番调查,找到了这个问题的根源。不知何故,docker 的主要服务停止了。

So if you could access the UI and after some time you couldn't, go to your task manager and search for Docker.Serviceto see if it is running, as you can see in the below picture.

因此,如果您可以访问 UI,但一段时间后无法访问,请转到任务管理器并搜索Docker.Service以查看它是否正在运行,如下图所示。

enter image description here

在此处输入图片说明

If you don't see it, you should run it manually. In my case I have it on my desktop it is called "Docker for Windows".

如果你没有看到它,你应该手动运行它。就我而言,我的桌面上有它,它被称为“Docker for Windows”。