Maven-Wrapper in jHipster inside Docker-Container: FileNotFoundException - bash

I installed docker inside a vm running on lubuntu 16.4. Afterwards I pulled the container jhipster/jhipster according to this tutorial. Accessing it with docker exec -it jhipster bash works fine, also the process of creating an app via yo jhipster. But when I want to run it using the maven wrapper via ./mvnw, the following error occurs (after just under a second):
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
Exception in thread "main" java.io.FileNotFoundException: /home/jhipster/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9-bin.zip.part (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at org.apache.maven.wrapper.DefaultDownloader.downloadInternal(DefaultDownloader.java:69)
at org.apache.maven.wrapper.DefaultDownloader.download(DefaultDownloader.java:60)
at org.apache.maven.wrapper.Installer.createDist(Installer.java:64)
at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:121)
at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
Inside the container seems to be no maven installed, but that is what the mvnw is for, right? Anyway, it's not possible to install maven on my own (inside the container) because of lacking su rights (sudo isn't found, su works "only from terminal").
I don't get what's wrong here... Can you help?
PS: The .m2-directory is empty.

I'm assuming you mapped your maven folder in the vm to the /home/jhipster/.m2 folder in the docker container, as as per the tutorial instructions. I found that if the vm did not already have maven installed, the ~/.m2 folder in the vm was created with root owner. Not sure how or why. As a result, the jhipster user in the docker container didn't have permission to write to the /home/jhipster/.m2 folder. You should be able to fix it by changing the owner of the folder (from within the vm) to the user you are using to run docker.

Related

Docker - The moduleSpecifier "..." couldn't be found on local disk

I cannot mount a local folder to a docker volume on docker-compose
so it is not accessible on docker-compose run cmd.
Here is a repo from the github https://github.com/up1/demo-k6-docker
When I follow readme on docker-compose run k6 run scripts/sample.js it gives me the following error all the time:
WARN[0000] The moduleSpecifier "scripts/sample.js" has no scheme but we will try to resolve it as remote module. This will be deprecated in the future and all remote modules will need to explicitly use "https" as scheme. ERRO[0000] The moduleSpecifier "scripts/sample.js" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker. Additionally it was tried to be loaded as remote module by prepending "https://" to it, which also didn't work. Remote resolution error: "Get "https://scripts/sample.js": dial tcp: lookup scripts on 127.0.0.11:53: no such host"
Tried:
specifically sharing folder in docker app settings window,
different github repos,
different mac laptops,
different setups Dockerfile copy and -v option on docker run
looking for similar questions
and docs
https://k6.io/docs/using-k6/modules#using-local-modules-with-docker
I would really appreciate some help, banging my head against the wall for a couple of days with this
Try this.
docker-compose run k6 run //scripts//sample.js
I'm running on docker desktop version 3.1.0 Windows 10 pro.
Solution

Connecting folder in a Docker container with a folder on local machine - Permission Denied

I'm new to docker and am trying to bind mount a folder in my docker container with a folder on my local machine. Using the code below, I was able to create the container with no issue.
docker run -it -v /Users/bdbot/Documents/mount_demo/:/mount_demo nycdsa/linux-toolkits bash
However, when I tried to create a txt file within the container folder, I got this error:
bash: demo.txt: Permission denied
Seeing that it was an access issue, I ran
sudo chmod 777 ../mount_demo
This allowed me to create the file, however when I checked the folder on my local machine it was not there. So the folders are not syncing.
I've also made sure the docker settings "Shared Drives" had the correct credentials. I'm not familiar enough with Docker to know how to trouble shoot further and have not been able to find anything online. I am using Windows, and everything is up to date.
The answer ended up being a really simple fix. The combination of using unix on a windows machine required that I add an additional slash(/) before the folder path. The below fixed this issue for me:
docker run -it -v //Users/bdbot/Documents/mount_demo/:/mount_demo nycdsa/linux-toolkits bash

Error in Maven goal inside Jenkins on Docker in Windows

I am trying to setup jenkins on docker in my windows machine. Everything was going smooth until I configured the maven goal in Jenkins. It looks like maven is overlooking the Jenkins_home path configured while starting the docker. I used the following command during startup
docker run -p 8080:8080 -p 50000:50000 -v //D/jenkins:/var/jenkins_home Jenkins
I also tried the following
docker run -p 8080:8080 -p 50000:50000 -v jenkins_home://D/jenkins_workspace jenkins
but I keep getting the error
[crazywebapp_dev] $ mvn clean install
FATAL: command execution failed java.io.IOException: error=2, No such
file or directory at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:247) at
java.lang.ProcessImpl.start(ProcessImpl.java:134) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) Caused:
java.io.IOException: Cannot run program "mvn" (in directory
"/var/jenkins_home/workspace/crazywebapp_dev"): error=2, No such file
or directory at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at
hudson.Proc$LocalProc.(Proc.java:249)
I believe it has got to do something with maven because the Jenkins workspace is getting created in my D: drive and the code is checked out successfully from bit bucket and the workspace contents shows up in Jenkins. I have also noticed that even though the workspace is created in my D: drive, Jenkins_home still shows up as /var/Jenkins_home in the Jenkins config page. Please help me figure this out.
I have also noticed that even though the workspace is created in my
D: drive, Jenkins_home still shows up as /var/Jenkins_home in the
Jenkins config page. Please help me figure this out.
From the containers perspective, there is no D: drive, the jenkins_home will always be /var/jenkins_home inside the container.
The syntax -v //D/jenkins:/var/jenkins_home means mount D:\jenkins onto /var/jenkins_home inside the container. This will effectively just replace or backup the containers jenkins home in the jenkins folder.
The syntax -v jenkins_home://D/jenkins_workspace is not useful. It means "create" a /D/jenkins_workspace directory inside the container and use a named volume called jenkins_home to backup this folder. This is not useful.
The main problem that you have, is that maven is not installed inside the jenkins container. Thus jenkins clearly can't find it. You need to configure maven to be installed. You can do that in jenkins, by going to:
Manage Jenkins > Configure System > Maven section and then configure it to install maven automatically.

pull access denied for oracle/serverjre

I have been trying to build a docker image for oracle/weblogic 12.2.1.
I followed all the instructions carefully as given in the official repo.
https://github.com/oracle/docker-images/tree/master/OracleWebLogic/dockerfiles/12.2.1.1
but when i run:
docker build -t oracle/weblogic:12.2.1.1-developer .
it gives me a permission denied error.
sudo docker build -t oracle/weblogic:12.2.1.1-developer .
Sending build context to Docker daemon 54.79MB
Step 1/13 : FROM oracle/serverjre:8
pull access denied for oracle/serverjre, repository does not exist or may require 'docker login'
can anyone please help me??
Thankyou
For some time now, it's needed not only to login with the Oracle account, but also to accept the license and user agreement. So you cannot do it only from command line. You must go to the Oracle container registry:
https://container-registry.oracle.com/
Then select Java repository, then select serverjre, then signin:
And accept the license:
Once you have done that, you'll be able to pull the docker image, but as other have said, you'll need to change the registry that is set inside the Dockerfile:
#FROM oracle/serverjre:8
FROM container-registry.oracle.com/java/serverjre:8
And afterwards, before running the build, you must do a docker login
docker login container-registry.oracle.com
username:<SSO USERNAME>
password:<SSO PASSWORD>
At this point, you'll be able to pull the image.
I followed the pattern used in the git hub project https://github.com/oracle/docker-images/tree/master/
If you checkout the project and go into the OracleJava directory and look at the *.download file (in this case for JRE 8: https://github.com/oracle/docker-images/blob/master/OracleJava/java-8/server-jre-8u151-linux-x64.tar.gz.download)
There is a link to download the tarball (after you accept the license agreement and sign in).
You can then place the tarball in the same directory as the build.sh (OracleJava/java-8).
Run: sh build.sh
This should then create the docker image of oracle/serverjre:8
You can should then be able to do your build and the instance of the image will be found locally.
If you're using a custom image with Dockerfile, Delete the oracle/ it's not your local repository.
Try docker build -t weblogic:12.2.1.1-developer .
Or just make a docker run [image]
I worked around the problem by having a docker image built for oracle/serverjre:8 in my machine.
I downloaded the oracle/Serverjre8 binaries and built a docker image then built the weblogic.And it worked !!
Alternately,you can pull the image for Oracle/ServerJre8 directly from Oracle container registry or Docker store by logging in first.
docker login container-registry.oracle.com
Username: <oracle sso="" username="">
Password: <oracle sso="" password="">
Login successful.
docker pull container-registry.oracle.com/java/serverjre:8
Considering WebLogic version 12.2.1.3, In case of PULL error and changing the registry to oracle registry, Below conditions should be checked-
While executing the script buildDockerImage.sh, make sure Dockerfile.developer (/docker-images/OracleWebLogic/dockerfiles/12.2.1.3/Dockerfile.developer) has entry to be changed-
#FROM oracle/serverjre:8
FROM container-registry.oracle.com/java/serverjre:8
User might need to be logged at oracle container registry for pull operation, so better is to login first prior to script execution.
docker login container-registry.oracle.com
username:<SSO USERNAME>
password:<SSO PASSWORD>
Also /docker-images/OracleWebLogic/dockerfiles/12.2.1.3/ contains fmw_12.2.1.3.0_wls_Disk1_1of1.zip.download file, that indicates necessary physical download of fmw_12.2.1.3.0_wls_Disk1_1of1.zip to be done from http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-for-dev-1703574.html and the same should be available at /docker-images/OracleWebLogic/dockerfiles/12.2.1.3/
Maybe when you created the Java image from OracleJava/8 you use the parameter version: 8-slim and with that image you try to create the weblogic image.
You just should use the version for default : Oracle Server JRE 8 on Oracle Linux 7 slim when create the OraclaJava image
build.sh for Oracle Java images
With that image of Java, you can create your weblogic image without problems, because that java image has tag: oracle/serverjre:8
echo "Building Oracle Server JRE 8 on Oracle Linux 7 slim"
docker build --tag oracle/serverjre:8 --tag oracle/serverjre:8-oraclelinux7 .

How to run Tomcat on Mac as external tool for Intellj Idea

I'm setting up my JavaEE environment with IntelliJ Idea 2016.3.5 at my Mac, Sierra. My Tomcat live at /usr/local/3th party app/appache-tomcat-8.0.36./. I'm not able to use another Tomcat, e.g. somewhere at /User folder, where I deploy the webapp.
Error running Tomcat: Cannot run program "/usr/local/app/apache-tomcat-8.0.36/" (in directory "/usr/local/app/apache-tomcat-8.0.36/bin"): error=13, Permission denied
My question:
How can I get the access to this Tomcat folder when I set the path to tool settings for IntelliJ's external tool?
You must ensure that you are able to read your tomcat directory.
Open terminal and locate your tomcat directory. Run this command:
chmod -R 777 usr/local/app/apache-tomcat-8.0.36/
That should allow you to run the tomcat server as an external tool in IntelliJ IDEA.

Resources