最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

gradle - Permission issue while creating a docker container for a micronaut application - Stack Overflow

programmeradmin6浏览0评论

I am learning Micronaut as this has been quite popular in the realm of cloud-native application development.

I have created a sample project using Gradle as the build tool. The following are the contents for the build.gradle.kts file.

plugins {
    id("com.gradleup.shadow") version "8.3.6"
    id("io.micronaut.application") version "4.4.4"
    id("io.micronaut.aot") version "4.4.4"
}

version = "0.1"
group = ".ablonewolf"

repositories {
    mavenCentral()
}

dependencies {
    annotationProcessor(".projectlombok:lombok")
    annotationProcessor("io.micronaut:micronaut-http-validation")
    annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
    implementation("io.micronaut.serde:micronaut-serde-jackson")
    compileOnly("io.micronaut:micronaut-http-client")
    compileOnly(".projectlombok:lombok")
    runtimeOnly("ch.qos.logback:logback-classic")
    testImplementation("io.micronaut:micronaut-http-client")
    implementation("io.projectreactor:reactor-core:3.6.2")
    testImplementation("io.projectreactor:reactor-test:3.6.2")
}


application {
    mainClass = ".ablonewolf.Application"
}
java {
    sourceCompatibility = JavaVersion.toVersion("21")
    targetCompatibility = JavaVersion.toVersion("21")
}


graalvmNative.toolchainDetection = false

micronaut {
    runtime("netty")
    testRuntime("junit5")
    processing {
        incremental(true)
        annotations(".ablonewolf.*")
    }
    aot {
        // Please review carefully the optimizations enabled below
        // Check / for more details
        optimizeServiceLoading = false
        convertYamlToJava = false
        precomputeOperations = true
        cacheEnvironment = true
        optimizeClassLoading = true
        deduceEnvironment = true
        optimizeNetty = true
        replaceLogbackXml = true
    }
}


tasks.named<io.micronaut.gradle.docker.NativeImageDockerfile>("dockerfileNative") {
    jdkVersion = "21"
}



When I try to create a docker container using this command ./gradlew clean dockerBuild, I get the following errors.


> Task :dockerfile
Dockerfile written to: /media/Primary-Volume/Courses/Udemy Courses/Micronaut/micronaut-intro/build/docker/main/Dockerfile
Error during callback
java.lang.RuntimeException: java.io.IOException: com.sun.jna.LastErrorException: [13] Permission denied
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:195)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:9)
        at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
        at com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
Caused by: java.io.IOException: com.sun.jna.LastErrorException: [13] Permission denied
        at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:63)
        at com.github.dockerjava.transport.LinuxDomainSocket.<init>(LinuxDomainSocket.java:41)
        at com.github.dockerjava.transport.DomainSocket.get(DomainSocket.java:140)
        at com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
        at com.bmuschko.gradle.docker.shaded.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
        ... 3 more
Caused by: com.sun.jna.LastErrorException: [13] Permission denied
        at com.github.dockerjava.transport.LinuxDomainSocket.connect(Native Method)
        at com.github.dockerjava.transport.LinuxDomainSocket.connect(LinuxDomainSocket.java:49)
        at com.github.dockerjava.transport.DomainSocket.open(DomainSocket.java:69)
        at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:59)
        ... 28 more

> Task :dockerBuild FAILED
Building image using context '/media/Primary-Volume/Courses/Udemy Courses/Micronaut/micronaut-intro/build/docker/main'.
Using Dockerfile '/media/Primary-Volume/Courses/Udemy Courses/Micronaut/micronaut-intro/build/docker/main/Dockerfile'
Using images 'micronaut-intro'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dockerBuild'.
> java.io.IOException: com.sun.jna.LastErrorException: [13] Permission denied

* Try:
> 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.
> Get more help at .

BUILD FAILED in 1s
7 actionable tasks: 7 executed

At first, I thought that this was mainly due to permission issues. So, I ran the command using super user privileges. However, I ran into another issue.

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Error while evaluating property 'javaCompiler' of task ':compileJava'.
   > Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
      > Toolchain installation '/usr/lib/jvm/java-21-openjdk' does not provide the required capabilities: [JAVA_COMPILER]

* Try:
> 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.
> Get more help at .

BUILD FAILED in 526ms
2 actionable tasks: 2 executed

I have installed Java using SDKMAN as I find it a convenient tool to manage tools related to the JVM ecosystem.

These the contents of the Docker file that's created during the runtime by the framework.

FROM eclipse-temurin:21-jre
WORKDIR /home/app
COPY --link layers/libs /home/app/libs
COPY --link layers/app /home/app/
COPY --link layers/resources /home/app/resources
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

I use Fedora KDE as my default driver. The current version of the OS is 41. How to address this particular issue?

发布评论

评论列表(0)

  1. 暂无评论