Spring boot from docker cannot find valid certification path for requested target error

I am using spring boot and trying to configure it with Docker . I tried everything I could find on google and nothing seems to turn me on. I am running

 mvn clean package docker:build 

Running this will execute spring-boot tags, perform DB reconfigurations, build a JAR, and then when it comes to creating a Docker image , I get the following error:

Failed to execute goal com.spotify:docker-maven-plugin:0.4.9:build (default-cli) 
on project app: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target -> [Help 1]

Here is the Docker file I'm using:

FROM java:8-jdk
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/james/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
EXPOSE 8080
VOLUME /tmp
ADD app-0.0.1-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

And here is my docker-maven-plugin configuration:

 ... pom stuff
<docker.image.prefix>jamesone1</docker.image.prefix>
    ... other pom stufff
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.9</version>
    <configuration>
            <dockerHost>https://192.168.99.100:2376</dockerHost>
            <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
            <dockerDirectory>src/main/docker</dockerDirectory>

            <resources>
                <resource>
                    <targetPath>/</targetPath>
                    <directory>${project.build.directory}</directory>
                    <include>${project.build.finalName}.jar</include>
                </resource>
            </resources>
    </configuration>
</plugin>

I am using a dock for mac and using a docker machine with the following env:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/james/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"

What's happening?! Did I miss something?

+4
2

10:

        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.13</version>
            <configuration>
                <imageName>yourImageName</imageName>
                <dockerDirectory>src/main/docker</dockerDirectory>
                <dockerHost>https://192.168.99.100:2376</dockerHost>
                <dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>

:

<dockerHost>https://192.168.99.100:2376</dockerHost>
<dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>

dockerfile, :

<dockerDirectory>src/main/docker</dockerDirectory>  

:

mvn package docker: build

, mac follwing :

<dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
+2

:

docker build -f Dockefile .

Dockefile ( ):

FROM java:8-jdk
EXPOSE 8080
#VOLUME /tmp

ADD target/app-0.0.1-SNAPSHOT.jar /opt/demo/app-0.0.1-SNAPSHOT.jar
CMD ["java","-jar","/opt/demo/app-0.0.1-SNAPSHOT.jar"]

:

 docker run <container id here>

mvn !

, docker-compose.yml, !!!

, , , dockerfile docker-compose, + !

docker-compose.yml, :

version: '2'
services:
  web:
    build: .
    ports:
     - "8080:8080"

build Dockerfile. * , , Dockerfile + yml !

ports , . localhost: 8080, .

:

https://docs.docker.com/compose/gettingstarted/

+1

Source: https://habr.com/ru/post/1653081/


All Articles