1

I have the following dockerfile.

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

This is build.gradle.

buildscript {
    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('se.transmode.gradle:gradle-docker:1.2')
    }
}

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'docker'



bootJar {
    baseName = 'gs-spring-boot-docker'
    version =  '0.1.0'
}


group = 'com.pai'
version = '0.0.1-SNAPSHOT'

task buildDocker(type: Docker, dependsOn: build){
    push = true
    applicationName = jar.baseName
    dockerfile = file('src/main/docker/Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}

repositories {
    mavenCentral()
}


dependencies {
    compile 'org.springframework.boot:spring-boot-starter-data-jpa'
    compile 'mysql:mysql-connector-java'
    compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.springframework.security:spring-security-test')
}

Process sync of build.gradle is successful. When I run the following command.

sudo ./gradlew build buildDocker

I get the following error message.

Execution failed for task ':buildDocker'.
> Docker execution failed
  Command line [docker push com.pai/pai201808:0.0.1-SNAPSHOT] returned:
  Get https://com.pai/v2/: dial tcp: lookup com.pai on 127.0.1.1:53: no such host

I think that this could be the issue of wrong import or invalid configurated dockerfile. How can I solve this problem?

1 Answer 1

2

Gradle script tries to push docker image to repository which doesn't exist. Do you intend to do that? If not - then just set push = false.

If you want to push the image to some repository, then you have to setup it. You have to check plugin specific settings of pushing image to repository you want.

More info: Creating new repository on Docker Hub, Setting up own registry

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.