I have a docker Image base on Tomcat 7. My web application start a instance of ActiveMQ. To build the container I add the following configuration docker run .... -p 61616:61616 ...
I can see the configuration on Docker Inspect command:
"Ports": {
"5005/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8091"
}
],
"61616/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "61616"
}
],
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8090"
}
]
},
Inside the container if I run:
telnet localhost 61616
i can connect to ActiveMQ instance:
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
▒ActiveMQTcpNoDelayEnabledSizePrefixDisabled CacheSizeStackTraceEnabled
CacheEnabledTightEncodingEnabledMaxInactivityDurationu0 MaxInactivityDurationInitalDelay'
From my host I can't:
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
I look for the port with netstat and is avaliable:
netstat -nao
tcp6 0 0 :::61616 :::* LISTEN 26503/docker-proxy off (0.00/0/0)
tcp6 0 0 :::8090 :::* LISTEN 26511/docker-proxy off (0.00/0/0)
tcp6 0 0 :::8091 :::* LISTEN 26519/docker-proxy off (0.00/0/0)
If I try to telnet to the other port, I can connect. What I'm missing?
I solved this problem configuring activeMQ networks with ip 0.0.0.0 Normally the ip was 127.0.0.1 and without dockerizing it, this worked. But inside the docker it didn't
This is my spring jms config (which uses activeMQ)
<amq:broker brokerName="${local.broker.name}" id="broker" persistent="false" deleteAllMessagesOnStartup="true" enableStatistics="false" useLoggingForShutdownErrors="true">
<amq:transportConnectors>
<amq:transportConnector uri="nio://${local.broker.ip}:${local.broker.port}?jms.useAsyncSend=true?jms.useCompression=true" disableAsyncDispatch="false" />
<amq:transportConnectors>
<amq:broker>
the application.properties was
local.broker.name=broker
local.broker.ip=127.0.0.1
local.broker.port=61617
changed it with
local.broker.name=broker
local.broker.ip=0.0.0.0
local.broker.port=61617