Unable to create image using mvn spring-boot:build-image command in docker

I am trying to use the following command in spring-boot using maven spring-boot plugin for generating docker image.

  1. The docker daemon is running on Ubuntu on WSL2 .
  2. STS terminal window was used to trigger the mvn spring-boot:build-image command.

I was expecting that an image be create in docker.
Instead I am getting the following error with maven build failed.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.3:build-image (default-cli) on project HelloWorld: Execution default-cli of goal org.springframewor
k.boot:spring-boot-maven-plugin:3.1.3:build-image failed: Connection to the Docker daemon at ‘localhost’ failed with error “\.\pipe\docker_engine”; ensure the Docker daemon is running
and accessible -> [Help 1]

The spring boot helloworld app is a simple application created using spring-starte-project in sts.

Any suggestions/solutions to overcome the issue?

I was expecting that an image be create in docker.
Instead I am getting the following error with maven build failed.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.3:build-image (default-cli) on project HelloWorld: Execution default-cli of goal org.springframewor
k.boot:spring-boot-maven-plugin:3.1.3:build-image failed: Connection to the Docker daemon at ‘localhost’ failed with error “\.\pipe\docker_engine”; ensure the Docker daemon is running
and accessible -> [Help 1]

The spring boot helloworld app is a simple application created using spring-starter-project in sts.

Any suggestions/solutions to overcome the issue?

  • …well, is the docker daemon running and is accessible from where you are running the app?

    – 




  • 1

    Do you run the terminal from which you start the command in windows or in wsl2?

    – 

Leave a Comment