I have a simple Java application that runs in the command line and connects to a local Apache Pulsar on port 6650 (pulsar://localhost:6650). I've jar'ed the application and dockerised it. The Apache Pulsar server is on the same machine as the dockerised app. However, when I run the docker container, it says Connection refused: localhost/127.0.0.1:6650.
I'm new to Docker so I believe it may be something I'm doing wrong with Docker. I've tried the following commands to run my container:
docker run -it -p 6650:6650 pulsar_logging_consumer
docker run -it --network="host" pulsar_logging_consumer
Dockerfile:
FROM openjdk:latest
COPY target/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar /usr/src/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar
EXPOSE 6650
CMD java -jar /usr/src/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar