Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exiting due to DRV_CREATE_TIMEOUT: Failed to start host: creating host: create host timed out in 600.000000 seconds #20346

Open
Rapter1990 opened this issue Feb 2, 2025 · 0 comments

Comments

@Rapter1990
Copy link

Rapter1990 commented Feb 2, 2025

What Happened?

I tried to implement an example of Spring Boot with Jenkins running on Docker.

I used Jenkins as CI/CD process

Here is the groovy file of Jenkins to create pipeline

import hudson.plugins.git.UserRemoteConfig
import hudson.plugins.git.BranchSpec
import hudson.plugins.git.GitSCM
import jenkins.model.*
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition

def instance = Jenkins.getInstance()

def jobName = "flightsearchapi"
def job = instance.getItem(jobName)

if (job != null) {
    job.delete()
}

def pipelineJob = instance.createProject(org.jenkinsci.plugins.workflow.job.WorkflowJob, jobName)
def definition = new CpsScmFlowDefinition(
        new GitSCM(
                [
                        new UserRemoteConfig("git-repo-url", null, null, null)
                ],
                [new BranchSpec("branch-name")],
                false, Collections.emptyList(),
                null, null, Collections.emptyList()
        ),
        "Jenkinsfile"
)
definition.setLightweight(true)
pipelineJob.setDefinition(definition)
pipelineJob.save()

println("Pipeline job '${jobName}' has been successfully created!")

Here is the plugin.txt

workflow-aggregator
git
job-dsl
ws-cleanup
docker-plugin
docker-workflow
docker-commons

Here is the Dockerfile

FROM jenkins/jenkins:lts

# Plugin list
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt

# For Groovy scripts, init.d directory
COPY init.groovy.d/ /var/jenkins_home/init.groovy.d/

# Install Docker CLI
USER root
RUN apt-get update && apt-get install -y docker.io

# Install kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
    && chmod +x kubectl \
    && mv kubectl /usr/local/bin/

# Install Minikube
RUN curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
    && chmod +x minikube-linux-amd64 \
    && mv minikube-linux-amd64 /usr/local/bin/minikube

Here is the docker-compose.yml

version: '3.9'

services:
  jenkins:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: jenkins-server
    ports:
      - "8080:8080"    # Expose Jenkins UI on port 8080
      - "50000:50000"  # Expose port for Jenkins agents
    volumes:
      - jenkins_home:/var/jenkins_home   # Persistent Jenkins data
      - /var/run/docker.sock.raw:/var/run/docker.sock # Mount Docker socket for Docker builds
      - ../k8s:/var/jenkins_home/k8s # Mount Kubernetes configuration files (optional)
      - ./init.groovy.d:/var/jenkins_home/init.groovy.d # Mount Jenkins init scripts (optional)
    environment:
      JAVA_OPTS: "-Djenkins.install.runSetupWizard=false" # Skip setup wizard (optional)
    user: root # Run as root to allow installing dependencies

volumes:
  jenkins_home:

Here is the Jenkinsfile

pipeline {
    agent any

    environment {
        GIT_REPO_URL = 'git-repo-url'
        BRANCH_NAME = 'branch-name'
        DOCKERHUB_USERNAME = 'dockerhub-name'
        DOCKER_IMAGE_NAME = 'docker-image-name'
    }

    stages {
        stage('Checkout') {
            steps {
                script {
                    checkout([
                        $class: 'GitSCM',
                        branches: [[name: "*/${env.BRANCH_NAME}"]],
                        userRemoteConfigs: [[url: "${env.GIT_REPO_URL}"]]
                    ])
                }
            }
        }

        stage('Build') {
            agent {
                    docker {
                        image 'maven:3.9.9-amazoncorretto-21-alpine'
                    }
                }
            steps {
                sh 'mvn clean install'
            }
        }

        stage('Build Docker Image') {
            agent {
                docker {
                    image 'docker:27.5.1'
                }
            }
            steps {
                sh "docker build -t ${env.DOCKERHUB_USERNAME}/${env.DOCKER_IMAGE_NAME}:latest ."
            }
        }

        stage('Push Docker Image') {
            agent {
                docker {
                    image 'docker:27.5.1'
                }
            }
            steps {
                withDockerRegistry([credentialsId: 'docker-hub-credentials', url: '']) {
                    sh "docker push ${env.DOCKERHUB_USERNAME}/${env.DOCKER_IMAGE_NAME}:latest"
                }
            }
        }

        stage('Deploy to Minikube') {
            agent any
            steps {
                script {

                    // Delete Minikube
                    sh "minikube delete"

                    // Start Minikube
                    sh "minikube start --force --memory=6000 --cpus=4 --wait-timeout=10m"

                    // Open Minikube dashboard (optional, runs in the background)
                    sh "minikube dashboard &"

                    // Apply Kubernetes configurations
                    sh "kubectl apply -f k8s"

                    // Optional: Verify deployment status
                    sh "kubectl get pods -A"
                }
            }
        }

    }

    post {
            always {
                cleanWs(cleanWhenNotBuilt: false,
                        deleteDirs: true,
                        disableDeferredWipeout: true,
                        notFailBuild: true,
                        patterns: [[pattern: '.gitignore', type: 'INCLUDE'],
                                   [pattern: '.propsfile', type: 'EXCLUDE']])
            }
    }
}

When I open Jenkins (localhost:8080) through docker-compose up -d --build and run pipeline , I got this error.

How can I fix the issue?

Attach the log file

+ minikube delete
! "minikube" profile does not exist, trying anyways.
* Removed all traces of the "minikube" cluster.
* Deleting container "minikube" ...
[Pipeline] sh
+ minikube start --force --memory=6000 --cpus=4 --wait-timeout=10m
* minikube v1.35.0 on Debian 12.8 (docker/amd64)
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Automatically selected the docker driver. Other choices: none, ssh
* The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/
* Using Docker driver with root privileges
! For an improved experience it's recommended to use Docker Engine instead of Docker Desktop.
Docker Engine installation instructions: https://docs.docker.com/engine/install/#server
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.46 ...
* Downloading Kubernetes v1.32.0 preload ...
* Creating docker container (CPUs=4, Memory=6000MB) ...
* Stopping node "minikube"  ...
* Powering off "minikube" via SSH ...
* Deleting "minikube" in docker ...
! StartHost failed, but will try again: creating host: create host timed out in 600.000000 seconds
* Creating docker container (CPUs=4, Memory=6000MB) ...
* Failed to start docker container. Running "minikube delete" may fix it: creating host: create host timed out in 600.000000 seconds

X Exiting due to DRV_CREATE_TIMEOUT: Failed to start host: creating host: create host timed out in 600.000000 seconds
* Suggestion: Try 'minikube delete', and disable any conflicting VPN or firewall software
* Related issue: https://github.com/kubernetes/minikube/issues/7072

Operating System

Windows

Driver

Docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant