Aidan Tweedy
Aidan Tweedy

Reputation: 33

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. in Google Chrome. This is with running the docker image using 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., which leads me to believe I'm doing something by adding the --net flag but I'm not sure why it can't connect. Maybe a port forwarding issue?

My Dockerfile is as follows

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>

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.

Upvotes: 0

Views: 1449

Answers (1)

Aidan Tweedy
Aidan Tweedy

Reputation: 33

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. I am now able to connect to my containerized AMQ instance from my host OS.

Upvotes: 1

Related Questions