1

因此,如果我curl -u admin:password http://10.0.1.195:8161/api/jolokia在 Docker 容器中运行,我将收到此错误:

curl: (7) Failed to connect to 10.0.1.195 port 8161: No route to host

但是,如果我在主机上的容器外运行相同的 cURL 命令,我就可以访问端口 8161 上的 ActiveMQ 主机。

此外,我可以curl http://10.0.2.111:8086/ping在同一个 Docker 容器中运行,它指的是 InfluxDB 主机。

我得出的结论是我的问题与 ActiveMQ 有关,因为我能够连接到其他任何地方。

ActiveMQ 运行在具有配置的安全组、子网和 VPC 的单独 EC2 实例上。一切正常,只有从 Docker 容器内部访问该主机是一个问题。

码头.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    ...
    <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
        <property name="host" value="0.0.0.0" />
        <property name="port" value="8161" />
    </bean>
    ...
    <bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
        <constructor-arg ref="Server" />
        <!-- see the jettyPort bean -->
        <property name="host" value="#{systemProperties['jetty.host']}" />
        <property name="port" value="#{systemProperties['jetty.port']}" />
    </bean>
    ...
</beans>

jolokia-access.xml

<?xml version="1.0" encoding="UTF-8"?>
<restrict>
    <remote>
        <host>127.0.0.1</host>
        <host>localhost</host>
        <host>10.0.0.0/16</host>
    </remote>
    <deny>
        <mbean>
            <name>com.sun.management:type=DiagnosticCommand</name>
            <attribute>*</attribute>
            <operation>*</operation>
        </mbean>
        <mbean>
            <name>com.sun.management:type=HotSpotDiagnostic</name>
            <attribute>*</attribute>
            <operation>*</operation>
        </mbean>
    </deny>
</restrict>
4

0 回答 0