Below is my docker-compose.yml, which is pretty much simple.
version: "3.7"
services:
book-api:
image: openjdk:11
container_name: book-api
volumes:
- ./target/demo-0.0.1-SNAPSHOT.jar:/bookapi.jar
command: ["java","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8080","-Dspring.profiles.active=local","-jar","bookapi.jar"]
ports:
- "8080:8080"
But when I do docker-compose up, I get the below error:
Creating book-api ... done
Attaching to book-api
book-api | Error: Unable to access jarfile bookapi.jar
book-api exited with code 1
I don't see an error with mounting volumes. jar file (target/demo-0.0.1-SNAPSHOT.jar) is created and is in the correct location.
I also tried to change command to below, thinking that was causing issue:
["java","-jar","bookapi.jar"]
But I'm getting the same error. I'm running docker-compose on mac.
To troubleshoot the issue, I changed the command to check the file paths, permissions etc.
command: >
sh -c "ls -l && pwd && java -jar bookapi.jar"
And then I see below results:
rahulraj#my-pc % docker-compose up
Starting book-api ... done
Attaching to book-api
book-api | total 46764
book-api | drwxr-xr-x 1 root root 4096 Jun 23 15:20 bin
book-api | -rwxrwxrwx 1 root root 47821378 Jun 27 15:25 bookapi.jar
book-api | drwxr-xr-x 2 root root 4096 Mar 19 13:46 boot
book-api | drwxr-xr-x 5 root root 340 Jun 28 06:50 dev
book-api | drwxr-xr-x 1 root root 4096 Jun 28 06:48 etc
book-api | drwxr-xr-x 2 root root 4096 Mar 19 13:46 home
book-api | drwxr-xr-x 1 root root 4096 Jun 22 00:00 lib
book-api | drwxr-xr-x 2 root root 4096 Jun 22 00:00 media
book-api | drwxr-xr-x 2 root root 4096 Jun 22 00:00 mnt
book-api | drwxr-xr-x 2 root root 4096 Jun 22 00:00 opt
book-api | dr-xr-xr-x 183 root root 0 Jun 28 06:50 proc
book-api | drwx------ 1 root root 4096 Jun 23 15:21 root
book-api | drwxr-xr-x 3 root root 4096 Jun 22 00:00 run
book-api | drwxr-xr-x 1 root root 4096 Jun 23 01:11 sbin
book-api | drwxr-xr-x 2 root root 4096 Jun 22 00:00 srv
book-api | dr-xr-xr-x 13 root root 0 Jun 28 06:50 sys
book-api | drwxrwxrwt 1 root root 4096 Jun 23 15:21 tmp
book-api | drwxr-xr-x 1 root root 4096 Jun 22 00:00 usr
book-api | drwxr-xr-x 1 root root 4096 Jun 22 00:00 var
book-api | /
book-api | Error: Unable to access jarfile bookapi.jar
book-api exited with code 1
Seems like the jar file is having full permissions, current working directory is / and path of jar file is /bookapi.jar. But the command java -jar /bookapi.jar is failing with the above mentioned error. I tried with java -jar bookapi.jar too.
Am I doing something wrong here? Kindly suggest. Thanks!
I'm not sure why it was not working while using only docker-compose.yml. So, the above mentioned issue is still a mystery unresolved, however I changed the docker config to below and no more issues observed.
Created a docker image of the application with a Dockerfile
From openjdk:11
copy ./target/app.jar app.jar
CMD ["java","-jar","app.jar"]
and then docker image build -t book-api .
Modified docker-compose.yml as below:
services:
book-api:
image: book-api
container_name: book-api
ports:
- "8080:8080"
and then docker-compose up worked without any issues and container is up and running.
Thank you #knittl for your inputs.
Related
I have tested with testng.xml and got the folder called allure-results on my linux host. This folder has many .json files
-rw-rw-r-- 1 root root 202 Jan 27 03:20 038526c0-e53c-4907-a04b-7061eff12e91-container.json
-rw-rw-r-- 1 root root 548 Jan 27 03:20 17bd74ad-1f5e-4ef9-9f21-b2ec85cfca47-container.json
-rw-rw-r-- 1 root root 419 Jan 27 03:20 1bd85195-ab0d-4e17-ab12-800e5037405f-container.json
-rw-rw-r-- 1 root root 195 Jan 27 03:20 1f6a2505-8c58-452d-a564-e7ffa9512599-container.json
-rw-rw-r-- 1 root root 837 Jan 27 03:20 4fb8431a-162a-4f33-889b-2e5ee5c01843-result.json
-rw-rw-r-- 1 root root 415 Jan 27 03:20 990031d8-60eb-4379-8864-aee237fed175-container.json
The docker-compose file I used to create a container is as below.
version: '2'
services:
allure:
image: "frankescobar/allure-docker-service"
environment:
CHECK_RESULTS_EVERY_SECONDS: 1
KEEP_HISTORY: 1
ports:
- "5050:5050"
volumes:
- $PROJECT_PATH/allure-results:/app/allure-results
- $PROJECT_PATH/allure-reports:/app/default-reports
The project name I created in allure-docker is test.
To generate allure report, I request this URL.
http://192.168.100.58:5050/allure-docker-service/generate-report?project_id=test but got nothing in there.
I can see the same .json files in the container's path as they are correctly mounted as a volume.
allure#0ff7067fedb0:/app/allure-results$ ll
total 36
drwxrwxr-x 2 root root 4096 Jan 27 03:20 ./
drwxr-xr-x 1 allure allure 4096 Dec 14 10:03 ../
-rw-rw-r-- 1 root root 202 Jan 27 03:20 038526c0-e53c-4907-a04b-7061eff12e91-container.json
-rw-rw-r-- 1 root root 548 Jan 27 03:20 17bd74ad-1f5e-4ef9-9f21-b2ec85cfca47-container.json
-rw-rw-r-- 1 root root 419 Jan 27 03:20 1bd85195-ab0d-4e17-ab12-800e5037405f-container.json
-rw-rw-r-- 1 root root 195 Jan 27 03:20 1f6a2505-8c58-452d-a564-e7ffa9512599-container.json
-rw-rw-r-- 1 root root 837 Jan 27 03:20 4fb8431a-162a-4f33-889b-2e5ee5c01843-result.json
-rw-rw-r-- 1 root root 415 Jan 27 03:20 990031d8-60eb-4379-8864-aee237fed175-container.json
allure#0ff7067fedb0:/app/allure-results$
Question What am I missing to get the allure report?
I found the answer myself.
To generate a report, actually, I don't have to generate it manually as this allure-docker generates reports automatically if new results in the results directory are detected.
To get the report, remove allure-docker-service from URL request. Hence, it should be like,
http://192.168.100.58:5050/generate-report?project_id=test
I have installed tomcat and deployed a java web application in that in Redhat.
My System property user.home is pointing to /opt/tomcat.
This application tries to access a file path like this
root = new File(rootPath);
if (!root.isDirectory()) {
throw new IllegalArgumentException("Root is not a directory!");
}
Now i want to access any folder outside /opt like a sibling to /opt, it results false in root.isDirectory(). But if a folder is inside /opt/tomcat then it is properly returning as true.
Both the folders /opt and /nasdata(folder which i want to access) have same permissions.
UPDATED
ls -la /opt
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 .
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 ..
drwxr-xr-x 10 tomcat tomcat 4096 Jul 26 21:20 tomcat
ls -la /opt/tomcat
drwxr-xr-x 10 tomcat tomcat 4096 Jul 26 21:20 .
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 ..
drwxr-x--- 2 tomcat tomcat 4096 Jul 21 16:15 bin
-rw-r----- 1 tomcat tomcat 18949 Jun 28 01:46 BUILDING.txt
drwxr-x--- 3 tomcat tomcat 4096 Jul 23 09:20 conf
-rw-r----- 1 tomcat tomcat 6210 Jun 28 01:46 CONTRIBUTING.md
drwxr-x--- 2 tomcat tomcat 4096 Jul 21 20:14 lib
-rw-r----- 1 tomcat tomcat 57092 Jun 28 01:46 LICENSE
drwxr-x--- 2 tomcat tomcat 4096 Jul 28 04:58 logs
lrwxrwxrwx 1 root root 9 Jul 26 21:20 nasdata -> /nasdata/
-rw-r----- 1 tomcat tomcat 2333 Jun 28 01:46 NOTICE
drwxr-x--- 2 tomcat tomcat 4096 Jul 23 09:20 .oracle_jre_usage
-rw-r----- 1 tomcat tomcat 3372 Jun 28 01:46 README.md
-rw-r----- 1 tomcat tomcat 6898 Jun 28 01:46 RELEASE-NOTES
-rw-r----- 1 tomcat tomcat 16507 Jun 28 01:46 RUNNING.txt
drwxr-x--- 2 tomcat tomcat 4096 Jul 23 09:34 temp
drwxr-x--- 9 tomcat tomcat 4096 Jul 23 09:37 webapps
drwxr-x--- 3 tomcat tomcat 4096 Jul 21 16:28 work
ls -la of my root folder. I am trying to access nasdata folder and giving /nasdata as the path.
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 .
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 ..
-rw-r--r-- 1 root root 0 Feb 4 20:43 .autorelabel
lrwxrwxrwx. 1 root root 7 Feb 4 20:39 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Feb 4 20:52 boot
drwxr-xr-x 19 root root 3220 Jul 21 14:04 dev
drwxr-xr-x. 89 root root 4096 Jul 21 21:00 etc
drwxr-xr-x. 2 root root 4096 Feb 4 20:39 home
drwxr-xr-x 3 root root 4096 Jul 21 16:55 home2
lrwxrwxrwx. 1 root root 7 Feb 4 20:39 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Feb 4 20:39 lib64 -> usr/lib64
drwxr-xr-x. 5 root root 1024 Jul 21 16:58 localhome
drwx------. 2 root root 16384 Feb 4 20:38 lost+found
drwxr-xr-x. 2 root root 4096 Dec 14 2017 media
drwxr-xr-x. 2 root root 4096 Dec 14 2017 mnt
drwxrwxr-x 2 root 9999 4096 Jul 26 16:58 nasdata
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 opt
dr-xr-xr-x 150 root root 0 Jul 21 14:04 proc
dr-xr-x---. 7 root root 4096 Jul 21 16:26 root
drwxr-xr-x 30 root root 980 Jul 21 16:46 run
lrwxrwxrwx. 1 root root 8 Feb 4 20:39 sbin -> usr/sbin
-rw-r--r-- 1 root root 127599309 Jul 21 20:53 sk
drwxr-xr-x. 2 root root 4096 Dec 14 2017 srv
dr-xr-xr-x 13 root root 0 Jul 21 14:04 sys
drwxrwxrwt. 14 root root 4096 Jul 28 03:43 tmp
drwxr-xr-x. 14 root root 4096 Jul 21 16:08 usr
drwxr-xr-x. 20 root root 4096 Feb 4 20:46 var
Best Regards,
Saurav
Some strange error has hit, this code was working earlier.
My tree:
LM0002254:SellerService$ ls -lrt
total 61512
drwxr-xr-x 3 tarun 826136866 96 Feb 8 14:16 gradle
-rw-r--r-- 1 tarun 826136866 168 Apr 23 13:26 gradle.properties
-rwxr-xr-x 1 tarun 826136866 5766 Apr 23 13:26 gradlew
-rw-r--r-- 1 tarun 826136866 2763 Apr 23 13:26 gradlew.bat
-rw-r--r-- 1 tarun 826136866 36 Apr 23 13:26 settings.gradle.kts
drwxr-xr-x 5 tarun 826136866 160 Apr 23 13:26 src
-rw-r--r-- 1 tarun 826136866 3868 Apr 23 22:39 build.gradle.kts
drwxr-xr-x 23 tarun 826136866 736 Apr 23 23:15 build
-rw-r--r-- 1 tarun 826136866 31282686 Apr 23 23:16 SellerService-jvm-1.0-SNAPSHOT.jar
-rwxr-xr-x 1 tarun 826136866 214 Apr 23 23:22 install-cloud.sh
-rw-r--r-- 1 tarun 826136866 148 Apr 23 23:39 Dockerfile
Docker file:
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY SellerService-jvm-1.0-SNAPSHOT.jar ./
CMD ["java", "-jar", "./SellerService-jvm-1.0-SNAPSHOT.jar"]
Am getting below error, not sure why. This same piece of code was running yesterday.
cmd which am using on gcloud.
gcloud builds submit --tag gcr.io/<projectname>
Error am getting:
Step 1/5 : FROM openjdk:8-jre-alpine
8-jre-alpine: Pulling from library/openjdk
e7c96db7181b: Already exists
f910a506b6cb: Already exists
b6abafe80f63: Pulling fs layer
b6abafe80f63: Verifying Checksum
b6abafe80f63: Download complete
b6abafe80f63: Pull complete
Digest: sha256:f362b165b870ef129cbe730f29065ff37399c0aa8bcab3e44b51c302938c9193
Status: Downloaded newer image for openjdk:8-jre-alpine
---> f7a292bbb70c
Step 2/5 : WORKDIR /app
---> Running in 76b0acf0c246
Removing intermediate container 76b0acf0c246
---> 4afe2649b879
Step 3/5 : COPY SellerService-jvm-1.0-SNAPSHOT.jar .
COPY failed: stat /var/lib/docker/tmp/docker-builder987483752/SellerService-jvm-1.0-SNAPSHOT.jar: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Docker is reading my .gitignore content and ignoring files and folder in it. I have ignored jar files in gitignore so its ignoring that while copying. Need to make sure .gitignore file is not having those files ignored which you are copying in docker file.
I'm trying to install JDK 14 on my linux machine. It's running SliTaz. I got the tar.gz file, and I moved it to the /usr/lib/jvm folder. I've done everything required with linking, etc.
Though when I run the java command it doesn't work. It also doesn't work when I run it in the jvm/jdk/bin directory.
I think it is an executable permissions error? Because I get output when I do file java in the directory:
ethan#elirium:/usr/lib/jvm/jdk/bin$ file java
java: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, not stripped
ethan#elirium:/usr/lib/jvm/jdk/bin$ java
-sh: java: not found
ethan#elirium:/usr/lib/jvm/jdk/bin$ ./java
-sh: ./java: not found
ethan#elirium:/usr/lib/jvm/jdk/bin$
These are the permissions of every file in the bin directory:
-rwxr-xr-x 1 root root 140868 Mar 11 2016 apt
-rwxr-xr-x 1 root root 139260 Mar 11 2016 extcheck
-rwxr-xr-x 1 root root 139284 Mar 11 2016 idlj
-rwxr-xr-x 1 root root 13280 Jul 26 20:02 jaotc
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jar
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jarsigner
-rwxr-xr-x 1 root root 13144 Jul 26 20:02 java
-rwxr-xr-x 1 root root 2801 Mar 11 2016 java-rmi.cgi
-rwxr-xr-x 1 root root 13192 Jul 26 20:02 javac
-rwxr-xr-x 1 root root 13200 Jul 26 20:02 javadoc
-rwxr-xr-x 1 root root 140868 Mar 11 2016 javah
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 javap
lrwxrwxrwx 1 root root 40 Jul 26 19:59 javaws -> /usr/lib/jvm/java-icedtea/jre/bin/javaws
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jcmd
-rwxr-xr-x 1 root root 13232 Jul 26 20:02 jconsole
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jdb
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jdeprscan
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jdeps
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jfr
-rwxr-xr-x 1 root root 139252 Mar 11 2016 jhat
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jhsdb
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jimage
-rwxr-xr-x 1 root root 13192 Jul 26 20:02 jinfo
-rwxr-xr-x 1 root root 13192 Jul 26 20:02 jjs
-rwxr-xr-x 1 root root 13192 Jul 26 20:02 jlink
-rwxr-xr-x 1 root root 13192 Jul 26 20:02 jmap
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jmod
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jpackage
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jps
-rwxr-xr-x 1 root root 13200 Jul 26 20:02 jrunscript
-rwxr-xr-x 1 root root 139404 Mar 11 2016 jsadebugd
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jshell
-rwxr-xr-x 1 root root 13200 Jul 26 20:02 jstack
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 jstat
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 jstatd
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 keytool
-rwxr-xr-x 1 root root 139260 Mar 11 2016 native2ascii
lrwxrwxrwx 1 root root 38 Jul 26 19:59 orbd -> /usr/lib/jvm/java-icedtea/jre/bin/orbd
lrwxrwxrwx 1 root root 41 Jul 26 19:59 pack200 -> /usr/lib/jvm/java-icedtea/jre/bin/pack200
lrwxrwxrwx 1 root root 44 Jul 26 19:59 policytool -> /usr/lib/jvm/java-icedtea/jre/bin/policytool
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 rmic
-rwxr-xr-x 1 root root 13160 Jul 26 20:02 rmid
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 rmiregistry
-rwxr-xr-x 1 root root 139276 Mar 11 2016 schemagen
-rwxr-xr-x 1 root root 13168 Jul 26 20:02 serialver
lrwxrwxrwx 1 root root 44 Jul 26 19:59 servertool -> /usr/lib/jvm/java-icedtea/jre/bin/servertool
lrwxrwxrwx 1 root root 43 Jul 26 19:59 tnameserv -> /usr/lib/jvm/java-icedtea/jre/bin/tnameserv
lrwxrwxrwx 1 root root 43 Jul 26 19:59 unpack200 -> /usr/lib/jvm/java-icedtea/jre/bin/unpack200
-rwxr-xr-x 1 root root 139268 Mar 11 2016 wsgen
-rwxr-xr-x 1 root root 139268 Mar 11 2016 wsimport
-rwxr-xr-x 1 root root 139268 Mar 11 2016 xjc
ethan#elirium:/usr/lib/jvm/jdk/bin$
Whats wrong here? What do I need to do to fix it?
I use windows7 64-bit
reference site : enter link description here
This problem isn't solve
[INFO] Final Memory: 44M/175M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.8.1:jar (module-javadocs) on project hadoop-common: ArchiverException: Error while creating archive: Problem creating jar: C:\hdfs\hadoop-common-project\hadoop-common\target\hadoop-common-2.2.0\bin\hadoop.dll (Access is denied) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] [enter link description here][1]
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :hadoop-common
please help me
Same problem here... :-(
EDIT : It works !!
Chmod the cygdrive with
chmod a+rw /cygdrive/c/hdfs/hadoop-2.2.0-src/hadoop-common-project/hadoop-common/target/hadoop-common-2.2.0/bin/*
I've seen is this :
ls -al C:\hdfs\hadoop-common-project\hadoop-common\target\hadoop-common-2.2.0\bin
drwxr-xr-x 1 AM341772 Domain Users 0 Mar 21 18:19 .
drwxr-xr-x 1 AM341772 Domain Users 0 Mar 21 17:05 ..
-rwxr-xr-x 1 AM341772 Domain Users 4993 Mar 21 17:05 hadoop
-rw-r--r-- 1 AM341772 Domain Users 7770 Mar 21 17:05 hadoop.cmd
-rwxr-xr-x 1 AM341772 Domain Users 50176 Mar 21 17:04 hadoop.dll
-rw-r--r-- 1 AM341772 Domain Users 6881 Mar 21 17:04 hadoop.exp
-rw-r--r-- 1 AM341772 Domain Users 11878 Mar 21 17:04 hadoop.lib
-rw-r--r-- 1 AM341772 Domain Users 347136 Mar 21 17:04 hadoop.pdb
-rw-r--r-- 1 AM341772 Domain Users 204944 Mar 21 17:04 libwinutils.lib
-rwxr-xr-x 1 AM341772 Domain Users 1837 Mar 21 17:05 rcc
-rwxr-xr-x 1 AM341772 Domain Users 40448 Mar 21 17:04 winutils.exe
-rw-r--r-- 1 AM341772 Domain Users 371712 Mar 21 17:04 winutils.pdb
ls -al /cygdrive/c/hdfs/hadoop-2.2.0-src/hadoop-common-project/hadoop-common/target/hadoop-common-2.2.0/bin
total 1044
drwxrwxrwx+ 1 AM341772 Domain Users 0 Mar 21 18:19 .
drwxr-xr-x+ 1 AM341772 Domain Users 0 Mar 21 17:05 ..
-rwxrwxrwx 1 AM341772 Domain Users 4993 Mar 21 17:05 hadoop
-rwxrwxrwx 1 AM341772 Domain Users 7770 Mar 21 17:05 hadoop.cmd
---------- 1 AM341772 Domain Users 50176 Mar 21 17:04 hadoop.dll
---------- 1 AM341772 Domain Users 6881 Mar 21 17:04 hadoop.exp
---------- 1 AM341772 Domain Users 11878 Mar 21 17:04 hadoop.lib
---------- 1 AM341772 Domain Users 347136 Mar 21 17:04 hadoop.pdb
---------- 1 AM341772 Domain Users 204944 Mar 21 17:04 libwinutils.lib
-rwxrwxrwx 1 AM341772 Domain Users 1837 Mar 21 17:05 rcc
---------- 1 AM341772 Domain Users 40448 Mar 21 17:04 winutils.exe
---------- 1 AM341772 Domain Users 371712 Mar 21 17:04 winutils.pdb
It's a cygwin problem ?
You probably have a process running that has a lock on that file.
Make sure all Java processes (and anything else that may be using that file, e.g. Winzip, command prompt windows) are stopped and to be sure you could restart your machine
Had the same problem, fixed by running chmod command from the Windows SDK command prompt:
chmod -R 777 <hadoop-common-folder>