I have a dokku container running a node.js app, my backend needs to use java8 to run some command lines. I have the following error message from my server:
[Error: Command failed: /bin/sh -c java
/bin/sh: 1: java: not found
]
How can I make java8 accessible inside my dokku container?
You need to create your own image based on current one (or modify your current Dockerfile if you already have it) and add java to it. How exactly to add java depends on base image and java which you need. Here the sample for ubuntu based image and oracle java8
After that you could run container from that image. You could use your local image or you could push your image to public or private registry.
Here Dockerfile documentation and best practices for it creation.
Related
I can run kubectl get secret/rabbitmq-expressmode -n expressmode in shell successfully.
However when I try to run it in java with either ProcessBuilder or Runtime.getRuntime().exec, the error:
Error from server (BadRequest): the server rejected our request for an unknown reason
is thrown out.
What's the possible reason?
Best approach would be to use official java client library.
Installation is pretty easy, and code examples shows you how to use it.
If the official one does not meet your requirements, there are also community-maintained client libraries:
Java (OSGi)
Java (Fabric8, OSGi)
Java
I had same issue but resolved by programmatically creating bash file containing kubectl... command I was trying to execute directly.
For example, create bash file and put your kubectl command there (i.e.: some-file.sh). Then try then executing it in bash process running within your java code (bash some-file.sh).
I am helping on a project which consists of a Docker stack with a bunch of services all working together. All of them start except for one.
Using docker service ps my-service --no-trunc gives me: task: non-zero exit(1)
Using docker service logs my-service gives me: Error: could not find or load main class
This particular container has a Java application running in support of a NodeJS server. After npm install, npm run init, npm run build, and mvn clean install, I was able to successfully build the Docker image. No errors.
However, now it's not actually starting. I can't figure out how to diagnose it any further. The error message doesn't tell me a whole lot. The Java code is old, but it should work, I never touched it.
Mainly, I don't know where to progress from here. Google searches turn up only stuff where they have access to a lot more debugging information, and I just don't have enough to go on. Java is not my strength. What am I missing?
UPDATE 3/21/19: Thanks to #VinDev, I was able to get some more detailed information (it should've been obvious to me to try this, but it's good to learn).
Used docker run --name TestMyContainer -it my-image bash to start up the container, then ran the normal starting command for the container in the stack, which is catalina.sh run. That gave me the following output:
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /docker-java-home/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Error: Could not find or load main class
UPDATE #2 3/21/19: I was able to solve the issue. I should've included more information: I'm on a Windows machine, but making Linux containers. I found the answer here: Tomcat startup - Error: Could not find or load main class
Windows had reverted the setenv.sh file to CRLF EOL. I changed it back in Visual Studio Code, ran the container again, and everything works!
Run docker service ls to see if the service shows up ...
also run docker service inspect my-service
This should give you a container id you can use to get the logs
docker logs CONTAINER_ID
You can also run the container by itself
docker run IMAGE_NAME
to see the result of just running it as a container
/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Seems it can't find bootstrap.jar or tomcat-juli.jar
Maybe not being copied by Dockerfile?
I added this to the original post, but adding it here as well to properly mark the question as answered:
I was able to solve the issue. I should've included more information: I'm on a Windows machine, but making Linux containers. I found the answer here: Tomcat startup - Error: Could not find or load main class
Windows had reverted the setenv.sh file to CRLF EOL. I changed it back in Visual Studio Code, ran the container again, and everything works!
I am trying to run java with docker image in gitlab.
Here is my docker file.
FROM java:latest
FROM perl
COPY . /
ENTRYPOINT ["/usr/bin/perl", "/myapp_entrypoint.pl"]
I was able to build docker image successfully and run perl commands but java commands are not working.
My application is a linux application and I am running 'java -version'. I am not getting any output completely blank output for version command.
What would be the issue? Do I need to add anything related linux as I am running 'java -version' as linux command?
You don't specify what OS you're running in your container, but the main issue is that you're blowing away your Java layer with another FROM directive.
From the documentation, emphasis mine:
Each FROM instruction clears any state created by previous instructions.
So I'd espouse a solution in which I install Perl (if I really needed to) after having my base Java image.
However, if you use the base OpenJDK images, Perl comes preinstalled, so that will simplify your Dockerfile significantly.
FROM openjdk:latest
COPY . /
ENTRYPOINT ["/usr/bin/perl", "/myapp_entrypoint.pl"]
I am trying to run the 'TableauSDKSample' java program on an Amazon EMR machine running Linux (64 bit) using my own custom jar. When I try to run my program, I get the following error:
A fatal error occurred while creating the extract:
Hyper Server did not call back on the callback port: process = 30320
Printing stack trace now:
com.tableausoftware.TableauException: Hyper Server did not call back on
the callback port: process = 30320
at com.tableausoftware.hyperextract.Extract.<init>(Unknown Source)
at com.samsung.tabluea.TableauSDKSample.createOrOpenExtract(TableauSDKSample.j
ava:119)
at com.samsung.tabluea.TableauSDKSample.main(TableauSDKSample.java:234)
Exiting now.
Here's what I did:
I downloaded the Extract API for C/C++/Java (64-bit) (.tar.gz file)
I untarred the above file in install-dir using tar -xvzf
extractapi-linux-x86_64-10-5-0.tar.gz
I created a jar using maven
for my very simple custom project having only one file
TableauSDKSample.java
To install the shared libraries, I copied all
the files from
install-dir/hyperextractapi-cpp-linux-gcc-x86_64-release-2017.4.0.127.r9c0f968e/lib64/tableausdk/
to /lib64/. By doing this, I avoid setting LD_LIBRARY_PATH
explicitly. See this for details: https://software.intel.com/en-us/articles/install-a-unix-including-linux-shared-library
Then I tried to run my program using
the following command:
sudo java -cp install-dir/hyperextractapi-cpp-linux-gcc-x86_64-release-2017.4.0.127.r9c0f968e/lib64/tableausdk/:install-dir/hyperextractapi-cpp-linux-gcc-x86_64-release-2017.4.0.127.r9c0f968e/lib64/tableausdk/Java/:/path/to/my/custom-jar.jar fully.qualified.MainClass
(where my main class is TableauSDKSample)
There is definitely no issue with the code as it is running on my local system where I use Eclipse IDE to run it. What am I doing wrong?
I'm creating a Dockerfile for our Spring Boot application. The application takes a couple of command line parameters. At the end of Dockfile:
CMD java -jar Application.jar --bucket=bucket.list --key=lost
But is it a best practice to hardcode the values for bucket and key in the Dockfile?
If it is ok, then I can live with that. Otherwise, I would like to know how to parameterize the Dockfile.
The application will be deployed on AWS, if that opens the door for more suggestions.
Docker design focused in being independent as far as possible of Host environment, including when building a Docker image. There were a request to let Docker build accessing to host environmental variables but it was rejected looking for independence of host machine. There it is also commented some workaround that could fit your problem.
Anyway, what is supposed to do Application.jar? If it's an application supposed to be running inside the container (and not in building time) the correct way to launch it is using a custom script run when you start the container. There you can set your credential or any other information you wish to be accessed from a environment variable, that can be set when launching the container: docker run -e "MYKEY=secret" -e "MYBUCKET=bucket" myuser/myapp /my/custom/script
You can use environment variables or build arguments.
Build arguments allow you to specify parameters that are applied at buildtime when you execute docker build using the --build-arg ARG_NAME=ARG_VALUE command line parameter.
Environment variables allow you to specify parameters that are applied at runtime when you execute docker run using the -e "ENV_NAME=ENV_VALUE" command line parameter.