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

后端 未结 2 1600
被撕碎了的回忆
被撕碎了的回忆 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 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 
    

    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/

提交回复
热议问题