This is my Dockerfile:
#Build java web app container image
FROM ubuntu
MAINTAINER wangyao
#Make java and tomcat install directory
RUN mkdir /usr/local/java
RUN mkdir /usr/local/tomcat
#Copy jre and tomcat into image
ADD jdk1.8.0_45.jdk /usr/local/java/
ADD apache-tomcat-7.0.62 /usr/local/tomcat/
ENV JAVA_HOME=/usr/local/java/Contents/Home
CMD cd /usr/local/tomcat;./bin/catalina.sh run
#Expose http port
EXPOSE 8080
Then i built it and try to start it:
wangyaos-MBP-3:flexcloud wangyao$ ls
Dockerfile apache-tomcat-7.0.62 jdk1.8.0_45.jdk
wangyaos-MBP-3:flexcloud wangyao$ docker build -t flexcloud .
Sending build context to Docker daemon 355.6 MB
Sending build context to Docker daemon
........
Successfully built 1f824d246b39
wangyaos-MBP-3:flexcloud wangyao$ docker run -i -t flexcloud
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/java/Contents/Home
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
/usr/local/java/Contents/Home/bin/java: 20: /usr/local/java/Contents/Home/bin/java: Syntax error: word unexpected (expecting ")")
wangyaos-MBP-3:flexcloud wangyao$
what does word unexpected (expecting ")") mean ?
I used $ ./bin/catalina.sh run without docker, and I can run it, but i why can not run it on the docker container ?
As indicated in the comments, the error Syntax error: word unexpected (expecting ")") is a shell script error, which implies that /usr/local/java/Contents/Home/bin/java is not actually the java executable.
Accessing the container with docker exec -it <container> bash and executing /usr/local/java/Contents/Home/bin/java -version shows us whats actually going on, as per #KingOfSocket's comment.
Related
I have a docker image of a Spring boot application which is created by a developer from a different team. I'm trying to run this image on my Mac.
This application expects a profile name while starting the application. The properties file corresponding to that profile tries to locate a config file on the host machine.
Contents of application-local.properties
spring.config.import=file:/Users/userName/app.properties
Docker command I tried:
docker run -p 8080:8080 -e "JAVA_OPTS=-Dspring.profiles.active=local" application-name:0.0.1
This command fails with this exception as it is not able to access the file on the host machine.
01:09:20.764 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource 'file [/Users/userName/app.properties]' via location 'file:/Users/userName/app.properties' cannot be found
I tried to use the -v flag to bind this directory on the host to some directory on the container but it still failed.
docker run -p 8080:8080 -v /Users/userName:/app -e "JAVA_OPTS=-Dspring.profiles.active=local" application-name:0.0.1
Exception-
02:50:36.882 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource 'file [/Users/userName/app.properties]' via location 'file:/Users/userName/app.properties' cannot be found
The ENTRYPOINT of this docker image is:
/bin/sh -c #(nop) ENTRYPOINT ["/bin/sh" "-c" "exec java $JAVA_OPTS -XX:+UseContainerSupport -Djava.security.egd=file:/dev/./urandom -jar /opt/app/app.jar"]
How can I run this application on my machine? Am I missing anything? TIA.
Team, Is it possible to use springBootUtility with OpenLiberty kernel-slim UBI images (e.g. - kernel-slim-java8-openj9-ubi) ?
https://openliberty.io/docs/21.0.0.7/reference/command/springbootUtility-thin.html
Because, it's giving an error as
Step 3/11 : RUN springBootUtility thin --sourceAppPath=/staging/fat-order-0.0.1-SNAPSHOT.jar --targetThinAppPath=/staging/thin-order-0.0.1-SNAPSHOT.jar --targetLibCachePath=/staging/lib.index.cache
---> Running in 3023c669c4d7
/bin/sh: springBootUtility: command not found
The springBootUtility is only working with OpenLiberty full UBI images
The kernel-slim image does not appear to have that command at all. Compare kernel-slim:
bash-5.1$ docker run --rm -it openliberty/open-liberty:kernel-slim-java8-openj9-ubi ls /opt/ol/wlp/bin
auditUtility binaryLog.bat productInfo securityUtility.bat serverSchemaGen
auditUtility.bat featureUtility productInfo.bat server serverSchemaGen.bat
binaryLog featureUtility.bat securityUtility server.bat tools
To full:
bash-5.1$ docker run --rm -it openliberty/open-liberty:full-java8-openj9-ubi ls /opt/ol/wlp/bin
auditUtility binaryLog.bat featureUtility pluginUtility securityUtility.bat springBootUtility
auditUtility.bat client featureUtility.bat pluginUtility.bat server springBootUtility.bat
batchManager client.bat jaxb productInfo server.bat tools
batchManager.bat ddlGen jaxrs productInfo.bat serverSchemaGen
binaryLog ddlGen.bat jaxws securityUtility serverSchemaGen.bat
There appears to be a hole in the documentation, since nothing indicates you need to do this, but you need to install the springBoot feature into Open Liberty before the command will be added. Copy your server.xml with spring boot specified into the image, then run features.sh:
COPY --chown=1001:0 server.xml /config/
RUN features.sh
After that, springBootUtility will be placed in the /opt/ol/wlp/bin dir and should be on the path as well for further Dockerfile directives to use.
I have vm environment which i have created using Microsoft azure cloud. I have installed docker in this vm. I can run docker image without specifying the any terminal like sh or bash and it is working. when i say
docker run -it hello-world --->> it works
docker run -it hello-world sh ---->>> it don't works.
actually i am working on a networking tool kathara where i have to start a virtual lab using many pcs and router and then i have to specify the terminal for them when i want to open any pc or router.
this is the actual error i am getting wheni start conatiner
"critical - 400 client error: bad request ("oci runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown")"
docker run -it hello-world runs the container's default command: ./hello. That works, because that's what the container is designed to do.
docker run -it hello-world /bin/bash tries to run /bin/bash inside the container. That doesn't work, because that's not what the container is designed to do. That command does not exist within the container.
If you want to run /bin/bash, choose a container that has /bin/bash.
This is even suggested in the output of docker run -it hello-world:
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
I am writing the bash script to run hyperledger fabric setup with 2 organisation, and i am trying to install chain-code to. It works well in manual, but i have create the bash script, i am trying to export ORDERER_CA using below command. please suggest me.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" -e "CORE_PEER_ADDRESS=peer0.org1.example.com:7051" -it cli export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
facing the error
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"export\": executable file not found in $PATH": unknown
You cannot export the variable while the docker is running.
You should set the environment variable inside the docker-compose.yaml environments section and then run the docker with docker-compose.
I am trying to build a sap java connector using springboot. To build this app we need sapjco3.jar and sapjco3.so.
I am using Hibersap library and have added the maven jar dependencies.
In the documentation it says to run the the app we need pass the java.library.path={path to the .so file} in java params.
The application is running fine in linux but I am facing :
Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: /usr/lib/libsapjco3.so: libuuid.so.1: cannot open shared object file: No such file or directory
when I am trying to run in Docker.
I have added this in my dockerfile. :
VOLUME ["/var/log/hip"]
ADD maven/#file# app.jar
COPY libsapjco3.so /usr/lib/libsapjco3.so
RUN chmod a+x -R /usr/lib/libsapjco3.so
RUN sh -c 'touch /app.jar'
CMD [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar --logging.path=/var/log/hip"]
and I am trying the path using:
System.setProperty("java.library.path","/usr/lib");
As I said, this is working in windows using dll and linux using but it is failing in docker running linux.
I had same problem (WSO2 Docker image and SAP integration), try to install "libuuid" package inside your Docker image. SAP connector was searching for libuuid, so I installed it and it started up. I was using Alpine Linux inside Docker image and this helped:
apk add libuuid