Creating Springboot image with Docker took box on windows 10 using spotify maven plugin - maven

I use docker tool box in my windows 10 home laptop. Trying to create a docker image using the springboot project I have been working on. Followed the tutorial at https://spring.io/guides/gs/spring-boot-docker/
Have been struggling with the error for past three days
Apr 03, 2019 11:52:57 AM com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://192.168.99.100:2376: Connection reset by peer: socket write error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46.027 s
[INFO] Finished at: 2019-04-03T11:52:57+05:30
[INFO] Final Memory: 63M/433M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.9:build (default-cli) on project IssueTracker: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: com.spotify.docker.client.shaded.org.apache.http.client.ClientProtocolException: Cannot retry request with a non-repeatable request entity: Connection reset by peer: socket write error -> [Help 1]
Many websites I look up said this could be something related to disabling TLS. I tried to expose the host, disable the tls but still the issue persists. Any help will be appreciated.
The following is my maven plugin config
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
</configuration>
</plugin>

Did you try to run this maven goal inside "Docker Quickstart Terminal"?

Related

create spring boot 2.7 'mvn spring-boot:build-image' with podman on macOS failed

I try to create an image with mvn spring-boot:build-image using podman but got
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) # sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO] > Pulled builder image 'docker.io/paketobuildpacks/builder#sha256:94e65320ba1682bc68cbbf1d4f63693bb62cc06c7077bfa3e3bccac7fdc10628'
[INFO] > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO] > Pulled run image 'docker.io/paketobuildpacks/run#sha256:3e889016680c0e2ef1e8b1bfdad2d6d34966c860a53ccfcfb3e269d48ed65fed'
[INFO] > Executing lifecycle version v0.14.1
[INFO] > Using build cache volume 'pack-cache-744ddec35876.build'
[INFO]
[INFO] > Running creator
[INFO] [creator] ERROR: initializing analyzer: getting previous image: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied
podman info:
host:
arch: amd64
buildahVersion: 1.26.1
cgroupControllers:
...
version:
APIVersion: 4.1.0
Built: 1651853754
BuiltTime: Fri May 6 18:15:54 2022
GitCommit: ""
GoVersion: go1.18
Os: linux
OsArch: linux/amd64
Version: 4.1.0
I already tried a lot. Set permissions on socket, run podman with root. The same with docker is working well.
podman create alpine ls works fine.
In my pom.xml I tried:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<!-- <host>unix:///Users/mike/.local/share/containers/podman/machine/podman-machine-default/podman.sock</host>
<host>unix:///run/user/1000/podman/podman.sock</host>
-->
<bindHostToBuilder>true</bindHostToBuilder>
</docker>
</configuration>
</plugin>
Any idea?
Update:
If I enable this line in pom.xml:
unix:///run/user/1000/podman/podman.sock
I get:
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) # sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
For anyone who runs into a similar issue with spring boot build-image, for example when using remote docker hosts
From what I understand:
the pull is done using your docker parameters in pom.xml or environment variables like DOCKER_HOST
Once the pull has been completed, creator will start a new container and run the next commands in this newly container
The connection to docker in the new container might not work, as the DOCKER_HOST might need to be different for access to docker within a new container. Within the "creator" container, /var/run/docker.sock is automatically mounted from the host system.
If you enable bindHostToBuilder, it'll pass the DOCKER_HOST (or the parameter in pom.xml) to the new container, but that might not be the correct docker hostname that is accessible from within the new container.
For me the solution was to not use bindHostToBuilder, but ensure that /var/run/docker.sock exists on the host system so that it can be mapped within the "creator" container, even though the pull happens with a different DOCKER_HOST (a remote docker)

Building docker image with spring boot 2.4.1 failes with "Missing 'io.buildpacks.stack.id' stack label" when behind a firewall

I'm, trying to build a docker image with ./mvnw -DskipTests spring-boot:build-image using spring boot 2.4.1 and java 11 (openjdk version "11.0.9" 2020-10-20 LTS) on RHEL7.
I do this on a host behind a strict firewall so I have to fetch the build- and runimage from a private repo. I have configured the spring-boot-maven-plugin to use this repo:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<builderRegistry>
<username>my-username</username>
<password>xxx</password>
<url>https://my-mirror.com</url>
<email>kaj.hejer#usit.uio.no</email>
</builderRegistry>
</docker>
<image>
<builder>my-mirror.com/library/docker.io-paketobuildpacks-builder:base</builder>
<runImage>my-mirror.com/library/docker.io-paketobuildpacks-run:base</runImage>
<name>my-mirror.com/my-group/my-app:latest</name>
<verboseLogging>true</verboseLogging>
</image>
</configuration>
</plugin>
The build fails with
[INFO] > Pulling builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder:base' 100%
[INFO] > Pulled builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder#sha256:cf90221a33966e42f8b1960123dea4406c65fc6a410142ded573ed850ccc313b'
[INFO] > Pulling run image 'my-mirror.com/library/docker.io-paketobuildpacks-run:base' 100%
[INFO] > Pulled run image 'my-mirror.com/library/docker.io-paketobuildpacks-run#sha256:56fb7587103da155db6d4f9434fd7e2f9e45d7540a062847fd84e9132a28101b'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.090 s
[INFO] Finished at: 2020-12-17T08:36:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image (default-cli) on project my-app: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image failed: Missing 'io.buildpacks.stack.id' stack label -> [Help 1]
[ERROR]
When I try to build a docker image the same way but without the configuration block for the spring-boot-maven-plugin on my mac which is not behind a firewall it works just fine.
Can it be SELinux releated in some way? sudo journalctl -f don't list anything when running the mvnw command.
Thanks in advance for any input or ideas!
-Kaj :)
On https://github.com/spring-projects/spring-boot/issues/24641 we found that I used the tag base instead of base-cnb. With tag base-cnb it worked fine.
Now I got a [creator] ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: permission denied but that is not related to this question.

initial setup for hippo CMS is frozen and ends with error message

i am trying to get started with Hippo CMS. According to the docs Get started with Hippo everything worked so far. But at the last step where you have to run
mvn -Pcargo.run (-Drepo.path=storage)
the installation process seems to be frozen and after at least 5 min finishes with this error message. No idea what to do, according to the docs Hippo Prerequisites everything is correct set up so far (Java and Maven Version).
The error message is as follows:
[INFO] --- cargo-maven2-plugin:1.6.5:start (cargo-run) # myhippoproject
--- [INFO] [2.ContainerStartMojo] Resolved container artifact
org.codehaus.cargo:cargo-core-container-tomcat:jar:1.6.5 for container
tomcat8x [INFO] [talledLocalContainer] Tomcat 8.x starting... [INFO]
[stalledLocalDeployer] Deploying
[/Users/Mangrove/Desktop/myhippoproject/cms/target/cms.war] to
[/Users/Mangrove/Desktop/myhippoproject/target/tomcat8x/webapps]...
[INFO] [stalledLocalDeployer] Deploying
[/Users/Mangrove/Desktop/myhippoproject/site/target/site.war] to
[/Users/Mangrove/Desktop/myhippoproject/target/tomcat8x/webapps]...
[WARNING] [stalledLocalDeployer] The WAR contains a context.xml file
which sets the path to [essentials], which means path set it the Cargo
configuration will be ignored by Tomcat [INFO] [stalledLocalDeployer]
Deploying
[/Users/Mangrove/Desktop/myhippoproject/essentials
/target/essentials.war]
to [/Users/Mangrove/Desktop/myhippoproject/target/tomcat8x/webapps]...
[INFO] [yer.DeployerWatchdog] Deployable
[http://localhost:8080/cargocpc/index.html] failed to finish deploying
within the timeout period [600000]. The Deployable state is thus
unknown. [WARNING] [talledLocalContainer]
org.codehaus.cargo.container.ContainerException: Deployable
[http://localhost:8080/cargocpc/index.html] failed to finish deploying
within the timeout period [600000]. The Deployable state is thus
unknown. [ERROR] Starting container
[org.codehaus.cargo.container.tomcat.
Tomcat8xInstalledLocalContainer#40f8f
5a8] failed, now stopping container [INFO] [talledLocalContainer]
Tomcat 8.x is stopping... [INFO] [talledLocalContainer] Tomcat 8.x is
stopped [INFO] -------------------------------------------------------
----------------- [INFO] BUILD FAILURE [INFO] ------------------------
------------------------------------------------ [INFO] Total time:
10:28 min [INFO] Finished at: 2018-05-13T15:57:13+02:00 [INFO] -------
-----------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-
plugin:1.6.5:start (cargo-run) on project myhippoproject: Cannot start
container
[org.codehaus.cargo.container.tomcat.
Tomcat8xInstalledLocalContainer#40f8f
5a8]: Deployable [http://localhost:8080/cargocpc/index.html] failed to
finish deploying within the timeout period [600000]. The Deployable
state is thus unknown. -> [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]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Any hint, advice, tipp, suggestion is very welcome, thanks.
Finally i solved it. The Maven setup was not correctly wired. In any case i had to reset my pc, and suddenly it works now. Also i had different java versions at the time. Great help was also the hippo forum Hippo Community Forum. Thanks guys.
The error just means that the container did not start. The connection refused in this case is just a symptom of how cargo checks if the container is up.
That being said, this is quite a long time to have to wait to start. You could try to increase the timeout, but even this timeout is too long for regular work purposes.
Things to try include increasing the timeout, increasing jvm memory, start over, or try a different computer. Also make sure the process is running with the right permissions.

How to use external sonar server for jHipster project

I am currently developing a spring boot application with jHipster and I want to use an existing sonar server from my company to analyze the code. JHipster only describes a way to use a build in sonar server from a docker container. Unfortunately that is not an option for me since my machine is running on Windows Server 2012, that is not supported by docker.
I already tried to start the maven build by adding the server url as a build parameter to the maven build, but it is ignoring it.
mvn clean test sonar:sonar -Dsonar.host.url=http://server-ip:server-port/ -Dsonar.login=login -Dsonar.password=pw
I am relatively new to the topic and was using the given command by the jhipster reference page (https://jhipster.github.io/code-quality/), so the test profile should be the correct one for this purpose.
When I run the command it ignores the given url paramter and still tries to use localhost where it expects the sonar in a docker container.
08:31:53.473 INFO - Create JDBC datasource for
jdbc:h2:tcp://localhost/sonar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55.017 s
[INFO] Finished at: 2017-06-12T08:31:53+00:00
[INFO] Final Memory: 65M/392M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project project: Fail to connect to database: Cannot load JDBC driver class 'org.h2.Driver' -> [
Help 1]
Since jHipster generates and configures a lot in the background I have no idea if I am missing something vital here. Maybe a configuration file I have to adjust? I really appreciate the help.
The pom.xml was generated by jHipster and the maven plugin is configured as followed:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
The version is set in the properties as:
<sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
I tried setting up my project on a linux vm with a running local docker sonar instance as suggested by the jHipster team and it was running fine, it is just very inconvenient for me since I have an available company sonar instance running in the intranet.
I also tried modifying my settings.xml as suggested and that was ignored, though it lead to a different looking error message:
[INFO] --- sonar-maven-plugin:3.2:sonar (default-cli) # project ---
[INFO] User cache: C:\Users\Administrator\.sonar\cache
[ERROR] SonarQube server [http://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:12 min
[INFO] Finished at: 2017-06-14T11:29:22+00:00
[INFO] Final Memory: 57M/408M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project project: Unable to execute SonarQube: Fail to download libraries from server: Status r
eturned by url [http://localhost:9000/batch_bootstrap/index] is not valid: [404] -> [Help 1]
Everything is explained in the sonar docs : https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
You should edit the settings.xml file in you ~/.m2directory with the following:
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
</settings>
Try to add the following line into the properties section of your pom.xml file.
<sonar.host.url>http://1.2.3.4:9000/</sonar.host.url>
With the IP address corresponding to your sonarqube server.

Unable to load the mojo 'sonar' - A required class is missing

Have been trying to set up sonar to run on my Jenkins instance at the end of each build. As there are restrictions on my work computer I have set up nexus to work as proxy so i can download artifacts from the central maven repository. Whenever I run my build it is successful and the tests pass however the sonar step fails.
[INFO] Building Customer 1.0-SNAPSHOT
[INFO] ---------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:2.3:sonar (default-cli) # Customer ---
[INFO] ---------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------
[INFO] Total time: 2.543s
[INFO] Finished at: Mon Mar 23 11:44:46 GMT 2015
[INFO] Final Memory: 8M/156M
[INFO] ---------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven- plugin:2.3:sonar (default-cli) on project Customer: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.3:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.codehaus.mojo:sonar-maven-plugin:2.3'. A required class is missing: Lorg/apache/maven/rtinfo/RuntimeInformation;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:2.3
The required class that is missing - org/apache/maven/rtinfo/RuntimeInformation
I have tried several steps to resolve this already including cleaning my repository and restarting the build. I have also tried different versions of sonar-maven-plugin. I am currently using maven 3.0.
Any advice would be greatly appreciated!
Try to use Apache Maven 3.2.5 in combination with org.codehaus.mojo:sonar-maven-plugin:2.7.1.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
<!-- ... -->
</plugins>
</build>

Resources