Permission denied on dockerBuildImage
RiccardoBarbieri opened this issue · 4 comments
Expected Behavior
The expected behaviour is the creation of the image as specified in the task
tasks.register<DockerBuildImage>("dockerize") {
dependsOn("createDockerfile")
group = "docker"
description = "Dockerize the spring boot application"
inputDir.set(layout.projectDirectory.dir("build/docker"))
images.add(displayName.split("'").elementAt(1).replace(".","").lowercase() +
":latest")
}
Current Behavior
The task fails with a Permission denied
error, at Task execution stacktrace a stacktrace of the error can be found
I think that the problem might be caused by the fact that docker needs elevated privileges to create images.
Steps to Reproduce (for bugs)
tasks.register<Dockerfile>("createDockerfile") {
dependsOn("bootDistTar")
val fileRegex: Regex = Regex("unibo.mapConfigurator-boot(.*)\\.tar")
val inputDir: Directory = layout.projectDirectory.dir("build/distributions")
group = "docker"
description = "Create Dockerfile"
val lastModified = inputDir.asFileTree.files.filter {
it.name.matches(fileRegex)
}.maxByOrNull { it.lastModified() }
from("openjdk:11")
exposePort(8015)
volume("/data")
addFile("./build/distributions/" + lastModified!!.name, "/")
workingDir(lastModified.name.removeSuffix(".tar") + "/bin")
defaultCommand("bash" ,"./" + lastModified!!.name.split("-")[0])
}
tasks.register<DockerBuildImage>("dockerize") {
dependsOn("createDockerfile")
group = "docker"
description = "Dockerize the spring boot application"
inputDir.set(layout.projectDirectory.dir("build/docker"))
images.add(displayName.split("'").elementAt(1).replace(".","").lowercase() +
":latest")
}
The task in question is dockerize
, that depends on the creation of the Dockerfile expressed in createDockerfile
task.
Your Environment
Platform: Ubuntu 22.04
Docker version: 24.0.5
What version of the plugin are you using? Is this the first time you are trying the plugin or did this used to work?
I am using the latest version, 9.3.2, and yes, this is the first time I tried to use this plugin.
Is there some configuration that needs to be done to grant permission to access the docker daemon socket?
You can try to see if the previous version 9.3.1 fixes the issue for you but it seems like an issue with connecting to the Docker daemon. Make sure that the Docker daemon is enabled.
I haven't heard back from you but I am sure it's a Docker configuration issue on your end. Closing the issue for now. Let me know if you want to discuss further.