Search code examples
jenkinskubectlminikube

Exposing local Docker daemon to minikube - Jenkins config.json: The system cannot find the path specified


I'm running Jenkins on Windows 10,installed Docker toolbox and minikube (also on Windows 10).

I can "map" local Docker images to minikube with this Powershell command: minikube docker-env | Invoke-Expression, everything works as expected.

I want to do the same using Jenkinsfile

stage('Build1') {
         steps {
            powershell """
            minikube docker-env | Invoke-Expression
            """

         }
      }

But Jenkins is looking for config.json file in wrong location:

powershell.exe : * 
At C:\Program Files (x86)\Jenkins\workspace\api-gateway_master@tmp\durable-355fdbbe\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (* :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

X Error getting config: CreateFile C:\Windows\system32\config\systemprofile\.minikube\profiles\minikube\config.json: The system cannot find the path specified.

config file is actually in userprofile path:C:\Users\username\.minikube\profiles\minikube\config.json.

Same error with shell command (Git for Windows)

stage('Build1') {
         steps {
           sh 'eval $(minikube docker-env)'

         }
      }



++ minikube docker-env
* 
X Error getting config: CreateFile C:\Windows\system32\config\systemprofile\.minikube\profiles\minikube\config.json: The system cannot find the path specified.

Also created brad new minikube with this switch:--insecure-registry windows 10 IP:5000

EDIT:After applying suggestion as per comment:

Created environment variable in Jenkins:

MINIKUBE_HOME=C:\Users\user\.minikube

Now getting:

++ minikube docker-env
* 
X Error getting host status
* Error: [MACHINE_DOES_NOT_EXIST] state: machine does not exist
* Suggestion: Run 'minikube delete' to delete the stale VM, or and ensure that minikube is running as the same user you are issuing this command with

Did minikube stop, deleted minikube VM from Virtual Box,deleted folder C:\Users\user\.minikube, minikube start, no errors, but when running Jenkins pipeline, same error.


Solution

  • No need to mess with minikube anymore

    • uninstalled minikube
    • uninstalled Docker Toolbox
    • installed Docker Desktop
    • On Docker desktop enabled Kubernetes (Settings-Kubernetes-enable Kubernetes)

    Now all docker images are available to Kubernetes and Jenkins