Mastering-Microservices-with-Java-Third-Edition icon indicating copy to clipboard operation
Mastering-Microservices-with-Java-Third-Edition copied to clipboard

mvn docker:build is failing

Open sandeep-sparrow opened this issue 2 years ago • 13 comments

could you please guide.

image

sandeep-sparrow avatar Jul 15 '23 18:07 sandeep-sparrow

I am trying to build this on windows platform.

sandeep-sparrow avatar Jul 17 '23 05:07 sandeep-sparrow

It looks like either the docker is not installed properly,or the shell you are running the maven build can't recognise the docker environment.

You may want to execute the following command in same shell you are running the build: eval "$(docker-machine env default)" if docker is installed properly. Then, try running the build again.

sharmasourabh avatar Jul 17 '23 06:07 sharmasourabh

$ eval $(docker-machine env default) bash: docker-machine: command not found

i am getting this response

sandeep-sparrow avatar Jul 17 '23 06:07 sandeep-sparrow

It means you must be using the latest Docker. docker-machine is deprecated in 2021.

Are you able to run any docker container locally and still facing issue while running the build in same shell? If you have installed Docker recently, you may want to restart your machine if you haven't.

sharmasourabh avatar Jul 17 '23 06:07 sharmasourabh

yes, docker got installed a fresh update, i will restart and let your know. Thanks again.

sandeep-sparrow avatar Jul 17 '23 07:07 sandeep-sparrow

the retstart did not help

sandeep-sparrow avatar Jul 17 '23 08:07 sandeep-sparrow

Did you try running any container in same shell and did it work? Could you please post the output with command here?

Also, did you set the DOCKER_HOST variable with correct daemon path?

sharmasourabh avatar Jul 17 '23 14:07 sharmasourabh

I am trying to run with a direct Dockerfile present in class path of another project and see if it works.

sandeep-sparrow avatar Jul 17 '23 15:07 sandeep-sparrow

SS of docker file

image

contents of Dockerfile

`#Start with a base image containing Java runtime FROM openjdk:17-slim as build

MAINTAINER eazybytes.com

Add the application's jar to the container

COPY target/accounts-0.0.1-SNAPSHOT.jar accounts-0.0.1-SNAPSHOT.jar

Execute the application

ENTRYPOINT ["java","-jar","/accounts-0.0.1-SNAPSHOT.jar"]`

Step1: created docker image cmd: docker build . -t eazybytes/accounts

docker image created successfully

image

Step2: run docker image in container, cmd: docker run -p 8080:8080 eazybytes/accounts

docker container runs success in this case

sandeep-sparrow avatar Jul 17 '23 15:07 sandeep-sparrow

image

when running the mvn docker:build command for dynamic creation of DockerFile, following error is encountered.

[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.13.9:build (default-cli) on project restaurant-service: Execution default-cli of goal org.jolokia:docker-maven-plugin:0.13.9:build failed: No url given, no DOCKER_HOST environment variable and no read/writable '/var/run/docker.sock' -> [Help 1]

sandeep-sparrow avatar Jul 17 '23 15:07 sandeep-sparrow

It seems, plugin docker-maven-plugin's version (0.13.9) doesn't support the latest Docker. You may want to update the plugin.

Latest version can be found at https://github.com/fabric8io/docker-maven-plugin, you may want to refer its user manual for the changes.

sharmasourabh avatar Jul 17 '23 16:07 sharmasourabh

`

    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.43.0</version>`

using abvoe plugin worked fine with the latest docker version

sandeep-sparrow avatar Jul 17 '23 17:07 sandeep-sparrow

@sharmasourabh can you please add me as collab on dev branch will checkin the latest maven-docker-plugin for user's having latest docker version installed on their system.

sandeep-sparrow avatar Jul 17 '23 18:07 sandeep-sparrow