0

I can properly launch this Java 8 application using this command from a bash shell:

java -cp "simple-queue-0.1-SNAPSHOT.jar:jms-1.1.jar:commons-logging-1.2.jar:activemq-all-5.13.3.jar" 
    -Dserver1="my1.domain.com" 
    -Dserver2="my2.domain.com" 
    -Dusername="user" 
    -Dpassword="passwd" 
     com.fusesource.activemq.exercises.simple.queue.SimpleProducer

I want to containerize this application, so here is my Dockerfile:

FROM store/oracle/serverjre:8
MAINTAINER <me@myco.com>

EXPOSE 4567

VOLUME /data

COPY build/libs/*.jar /usr/local/bin/
COPY /app/simple-queue-0.1-SNAPSHOT.jar /usr/local/bin/

CMD ["java", "-cp", "/usr/local/bin/simple-queue-0.1-SNAPSHOT.jar:/usr/local/bin/jms-1.1.jar:/usr/local/bin/commons-logging-1.2.jar:/usr/local/bin/activemq-all-5.13.3.jar", "-Dserver1=$SERVER1", -Dserver2="$SERVER2", -Dusername="$USER", -Dpassword="$PASSWORD"]

I start my container like this:

docker run -it --rm -e SERVER1=my1.domain.com -e SERVER2=my2.domain.com -e USER=user -e PASSWORD=passwd ecosystem/simple-queue-client:1.1 com.fusesource.activemq.exercises.simple.queue.SimpleProducer

And I get this error message:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"com.fusesource.activemq.exercises.simple.queue.SimpleProducer\": executable file not found in $PATH": unknown.

When I get into that container, I can see that my jar files are in fact inside /usr/local/bin directory which is in the PATH. The CLASSPATH in the container is empty...

What do I need to do to fix this?

JamesD
  • 679
  • 10
  • 36
  • 1
    Does this answer your question? [docker: executable file not found in $PATH](https://stackoverflow.com/questions/27158840/docker-executable-file-not-found-in-path) – mikeb Jan 24 '20 at 00:17
  • 2
    I think you tried to pass in an additional parameter to your entrypoint, but what you actually did is override the command altogether. Read up on CMD vs ENTRYPOINT. – Thilo Jan 24 '20 at 00:17
  • When I have it like this, it works: ```ENTRYPOINT java -classpath /usr/local/bin/simple-queue-0.1-SNAPSHOT.jar:/usr/local/bin/jms-1.1.jar:/usr/local/bin/commons-logging-1.2.jar:/usr/local/bin/activemq-all-5.13.3.jar -Dserver1=$SERVER1 -Dserver2=$SERVER2 -Dusername=$USER -Dpassword=$PASSWORD com.fusesource.activemq.exercises.simple.queue.SimpleProducer``` but I need to feed the classname as input to the container at run-time, and I can't get it to tack anything on to the end of that ENTRYPOINT... – JamesD Jan 24 '20 at 06:01

1 Answers1

0

I used info from the link provided by midelb above and ended up with two containers: one for SimpleProducer and another for SimpleReceiver.

Here is the Docker file for one:

FROM store/oracle/serverjre:8
MAINTAINER <james.depaul@maxar.com>

VOLUME /data

COPY build/libs/*.jar /usr/local/bin/
COPY /app/simple-queue-0.1-SNAPSHOT.jar /usr/local/bin/

ENTRYPOINT java -classpath /usr/local/bin/simple-queue-0.1-SNAPSHOT.jar:/usr/local/bin/jms-1.1.jar:/usr/local/bin/commons-logging-1.2.jar:/usr/local/bin/activemq-all-5.13.3.jar -Dserver1=$SERVER1 -Dserver2=$SERVER2 -Dusername=$USER -Dpassword=$PASSWORD com.fusesource.activemq.exercises.simple.queue.SimpleConsumer

Build

docker build -t mysystem/simple-client-consumer:1.0

And I call it like this now:

docker run -d --rm -e SERVER1=server-b0.domain.com -e SERVER2=server-b1.domain.com -e USER=user -e PASSWORD=passwd mysystem/simple-client-consumer:1.0 
JamesD
  • 679
  • 10
  • 36