Spring boot with docker unable to find valid certification path to requested target error

后端 未结 2 1577
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 14:39

I\'m using spring boot and am trying to set it up with Docker. I\'ve tried everything I could find on google and nothing seems to get me going. I\'

相关标签:
2条回答
  • 2021-01-13 14:59

    fixed this in windows 10 by:

            <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>
    

    Important are these two tags:

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

    I am using a dockerfile, which path you have to define with this tag:

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

    Now you can build your jar and generate docker image via:

    mvn package docker:build

    I think on mac just follwing value has to be different:

    <dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
    
    0 讨论(0)
  • 2021-01-13 15:01

    I ended up building the docker image by myself without the plugin:

    docker build -f Dockefile .
    

    And my Dockefile (has been renamed):

    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"]
    

    I then run it like so:

     docker run <container id here>
    

    I just couldn't get the mvn plugin to work!

    Edit

    Furthermore I ended up creating a docker-compose.yml which makes things a lot simpler!!!

    You define properties such as the ports you want open, dockerfile location, and run docker-compose, and it'll magically build+run the docker image!

    Example docker-compose.yml that I'm using:

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

    build references the Dockerfile location. *Note you may need to the Dockerfile+yml file to be in the same location!

    ports reference the ports I want open. Now I can goto localhost:8080 and my request will be forwarded to the docker container.

    Read more on docker container here:

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

    0 讨论(0)
提交回复
热议问题