How to transfer files between local machine and minikube?

17,676

Solution 1

I handled it by following next steps:

1- going into ssh of minikube >> minikube ssh

2- Changing docker password using sudo >> sudo passwd docker and create new password so now i know docker user password

3- exit from ssh and go back to Ubuntu terminal >> exit

4- using scp command to copy files into minikube >> scp /local/path/to/file/ docker@minikubeIp:/your/destination/folder/

For example scp -r /media/myuser/sourceFolder [email protected]:/home/docker

and after that it asked only for minikube docker user password which i know it now after changed it then write password and folders copied successfully into minikube from local machine

Solution 2

On the host machine you can use the ssh-key and ip subcommands of the minikube command:

scp -i $(minikube ssh-key) <local-path> docker@$(minikube ip):<remote-path>

So the command from the question becomes:

scp -i $(minikube ssh-key) /media/myuser/sourceFolder docker@$(minikube ip):/home/docker/destiationFolder

Solution 3

At minikube 1.7, if using the VirtualBox driver, there exists a /hosthome folder mounted inside the minikube VM. This is a VirtualBox shared folder mapping to /home of the host system.

So, practically, if you ssh to the minikube VM everything from your home folder is readable and you can use normal cp commands to copy things around.

Solution 4

you can use kubectl cp command. https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp

Solution 5

 You can use minikube cp to copy the specified file into minikube.

minikube cp <source file path> <target node name>:<target file absolute path> [flags]

 If you don't know the target node name, you can run minikube node list first to get the node name. More info could be found in the official doc.

Share:
17,676
mibrahim.iti
Author by

mibrahim.iti

I am a developer who have an excellent organizational ability - working well under pressure, helpful, manage stress, managing resources to meet customer requirements, resourceful, trustworthy team member with good communications skills who also has the initiative to work efficiently on his own, a problem solver, using analytical, logical abilities in fault finding, interactive and fast enough to learn new technologies and sciences. I am always seeking a challenging position with a dynamic corporation where my academic background, my experience and interpersonal skills can be applied and further developed.

Updated on June 10, 2022

Comments

  • mibrahim.iti
    mibrahim.iti almost 2 years

    I am using OS Ubuntu 16.0.4 and i installed minikube on it. I need to copy some files to minikube, so how can i do that? I tried next command but it asked me on password and i don't know it

    scp /media/myuser/sourceFolder [email protected]:/home/docker/destiationFolder
    

    Note: minikube IP is 192.168.99.100, and i used docker as default user for minikube but actually i don't know if it correct ot not.

    So what is the default username and password for minikube and how can i copy files from my local machine into minikube?

    Thanks :)