docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 285 forks source link

gradle build is not working inside the docker. #13635

Open maheshshelke33821 opened 1 year ago

maheshshelke33821 commented 1 year ago

Description

I'm able to run gradle build command locally and it is a success. But when I use gradle build inside Dockerfile i'm not able to build an image out of it.

it gives error:

0 2.983

0 2.983 FAILURE: Build failed with an exception.

0 2.983

0 2.983 * Where:

0 2.983 Build file '/home/gradle/src/build.gradle' line: 2

0 2.983

0 2.983 * What went wrong:

0 2.983 Plugin [id: 'org.springframework.boot', version: '2.1.4.RELEASE'] was not found in any of the following sources:

0 2.983

0 2.983 - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)

0 2.983 - Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.4.RELEASE')

0 2.983 Searched in the following repositories:

0 2.983 Gradle Central Plugin Repository

0 2.983

0 2.983 * Try:

0 2.983 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

0 2.984

0 2.984 * Get more help at https://help.gradle.org

0 2.984

0 2.984 BUILD FAILED in 2s

here is my build.gradle file plugins { id 'org.springframework.boot' version '2.1.4.RELEASE' id 'java' }

apply plugin: 'io.spring.dependency-management'

group = 'io.codefresh' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8'

repositories { mavenCentral() }

dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' }

test { useJUnit()

maxHeapSize = '1G'

}

Reproduce

Dockerfile FROM gradle:4.7.0-jdk8-alpine AS build COPY --chown=gradle:gradle . /home/gradle/src WORKDIR /home/gradle/src RUN gradle build --no-daemon FROM openjdk:8-jre-slim EXPOSE 8080 RUN mkdir /app COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/spring-boot-application.jar"]

build.gradle plugins { id 'org.springframework.boot' version '2.1.4.RELEASE' id 'java' } apply plugin: 'io.spring.dependency-management group = 'io.codefresh' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' } test { useJUnit() maxHeapSize = '1G' }

On Running docker build . we get error

Expected behavior

should build successfully and create image

docker version

Client:
 Cloud integration: v1.0.33
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    24.0.2                                                 
 Context:    default                                                
 Debug Mode: false                                                  
 Plugins:                                                           
  buildx: Docker Buildx (Docker Inc.)                               
    Version:  v0.10.5                                               
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe 
  compose: Docker Compose (Docker Inc.)                             
    Version:  v2.18.1                                               
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  dev: Docker Dev Environments (Docker Inc.)                        
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe

Diagnostics ID

BE5AB60B-1C8B-45D7-A8FC-18FE8A5C686D/20230807141601

Additional Info

Here is the link for repository: https://github.com/codefresh-contrib/gradle-sample-app

sweller999 commented 6 months ago

bump. Having this issue as well

al-jeyapal commented 2 weeks ago

Kicking over docker resolved it for me:

sudo systemctl stop docker

# Verify
sudo systemctl status docker

sudo systemctl start docker

Build worked fine from that point onwards. Not certain what cause Docker to be unhappy.