简体   繁体   English

无法连接到在 Docker 容器中运行的 ActiveMQ 控制台

[英]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>

  • Note: Some sensitive info was removed, anything surrounded by <> 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.

相关问题 无法在Docker容器中输入ipdb控制台 - Can't type in ipdb console in docker container 无法连接到 Docker 容器中的 PostgreSQL 数据库 - Can't connect to PostgreSQL database in Docker container 无法通过 docker 容器连接到 RabbitMQ - Can't connect to RabbitMQ via docker container 容器化的 python 应用程序无法连接到在 Docker 容器上运行的 RabbitMQ 服务器 - Containerized python app can't connect to RabbitMQ server running on Docker container 将Spyder连接到远程主机上Docker容器中的控制台 - Connect Spyder to a console in a docker container on a remote host 为什么我无法连接到docker容器中的flask服务器? - Why can't I connect to the flask server in docker container? 如何通过运行带有URL的docker容器来连接docker容器中的python应用 - how to connect python app in docker container with running docker container with url Windows 客户端无法与在 linux docker 容器中运行的服务器通信 - Windows client can't communicate with server running in linux docker container 在 docker 容器中运行时,无法将 geopandas 导入 python - Can't import geopandas to python when running in docker container Mordecai:无法连接到本地运行的 Elasticsearch 容器 - Mordecai: Can't connect to Elasticsearch container running locally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM