[英]Can't connect to ActiveMQ Console running in Docker container
I made a Dockerfile
to run an ActiveMQ service from, and when I try to connect to the console on the host machine using http://127.0.0.1:8161/
in my web browser, it says 127.0.0.1 didn't send any data.
I made a
Dockerfile
to run an ActiveMQ service from, and when I try to connect to the console on the host machine using http://127.0.0.1:8161/
in my web browser, it says 127.0.0.1 didn't send any data.
in Google Chrome.在谷歌浏览器中。 This is with running the docker image using
docker run -p 61613:61613 -p 8161:8161 -it service_test bash
.这是使用
docker run -p 61613:61613 -p 8161:8161 -it service_test bash
。
However, when I run it using docker run --net host -it service_test bash
, Google Chrome says 127.0.0.1 refused to connect.
但是,当我使用
docker run --net host -it service_test bash
,谷歌浏览器说127.0.0.1 refused to connect.
, which leads me to believe I'm doing something by adding the --net
flag but I'm not sure why it can't connect. ,这让我相信我正在通过添加
--net
标志来做某事,但我不确定它为什么无法连接。 Maybe a port forwarding issue?也许是端口转发问题?
My Dockerfile is as follows我的Dockerfile如下
FROM <...>/library/ubuntu:20.04
ADD <proxy certs>
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \
update-ca-certificates && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
git \
python3.8 \
python3.8-venv \
python3.8-dev \
openjdk-11-jdk \
make \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt
RUN <point pip to certs>
RUN echo "timeout = 300" >> /etc/pip.conf
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python3.8 get-pip.py
# Run python in a venv
ENV VIRTUAL_ENV=/opt/venv
RUN python3.8 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Update pip before continuing
RUN pip install --upgrade pip
# Get wheel
RUN pip install wheel
# add extra index url
RUN echo "extra-index-url = <url>" >> /etc/pip.conf
# Install ActiveMQ
ENV JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
ENV PATH="$JAVA_HOME/bin:$PATH"
RUN mkdir -p /opt/amq
RUN curl -kL \
http://archive.apache.org/dist/activemq/5.16.3/apache-activemq-5.16.3-bin.tar.gz \
>> /opt/amq/apache-activemq-5.16.3-bin.tar.gz && \
tar -xzf /opt/amq/apache-activemq-5.16.3-bin.tar.gz --directory /opt/amq
ENV PATH="/opt/amq/apache-activemq-5.16.3/bin:$PATH"
# Expose ports 61613 and 8161 to other containers
EXPOSE 61613
EXPOSE 8161
COPY <package>.whl <package>.whl
RUN pip install <package>
<>
has been hidden.<>
包围的东西都被隐藏了。 For context, I am running activemq from the container using activemq console
, and trying to connect to it from my host OS using Google Chrome.对于上下文,我正在使用
activemq console
从容器运行 activemq,并尝试使用 Google Chrome 从我的主机操作系统连接到它。
Got it to work!让它工作!
For those having the same issue, I resolved it by changing the IP address in jetty.xml
from 127.0.0.1
to 0.0.0.0
.对于那些有同样问题的人,我通过将 jetty.xml 中的
jetty.xml
地址从127.0.0.1
更改为0.0.0.0
来解决它。 I am now able to connect to my containerized AMQ instance from my host OS.我现在可以从我的主机操作系统连接到我的容器化 AMQ 实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.