Docker minikube共享卷在一段时间后不显示文件

Docker minikube共享卷在一段时间后不显示文件,docker,kubernetes,minikube,Docker,Kubernetes,Minikube,我必须将本地.ssh目录内容共享到pod。我搜索了一下帽子,从其中一个帖子中得到了答案,作为开始分享 $minikube start--mount string=“$HOME/.ssh/:/ssh directory”--mount 在ubuntu上复制时,我遇到了确切的问题 目录看起来确实像是挂载的,但是文件丢失了,这让我认为这是使用docker驱动程序挂载目录的一般问题 github上也有关于相同问题()和open feature request的未决问题 检查minikube容器不会显示已

我必须将本地
.ssh
目录内容共享到pod。我搜索了一下帽子,从其中一个帖子中得到了答案,作为开始分享

$minikube start--mount string=“$HOME/.ssh/:/ssh directory”--mount

在ubuntu上复制时,我遇到了确切的问题

目录看起来确实像是挂载的,但是文件丢失了,这让我认为这是使用docker驱动程序挂载目录的一般问题

github上也有关于相同问题()和open feature request的未决问题

检查minikube容器不会显示已装入的卷的任何记录,并确认github请求中提到的信息,即到目前为止,与主机共享的唯一卷是默认装入的卷(即装入minikube的
/var/lib/docker/volumes/minikube/_data
目录)

作为解决方法,您可以使用以下命令将
.ssh
目录复制到正在运行的minikube docker容器中:

docker cp$HOME/.ssh minikube:

然后将所需目录装入pod。

您是否尝试在yml文件中直接引用hosthome?在您的案例中,这个“hosthome/.ssh”有一个特殊的键名,请查看驱动程序部分(页面底部):如果您这样做,您就不必在minikube Start中装载
--mount string=“$HOME/.ssh/:/ssh目录”
,一般来说,您不能用Kubernetes装载这样的文件。(这可能适用于Minikube或Kind之类的桌面安装,但不适用于更典型的群集安装。)您可以将此密钥放入一个秘密中,而不依赖于文件系统内容吗?@yAzou我有MacOS Minikube destop。@DavidMaze我按照答案共享本地文件夹,谢谢,我可能更喜欢秘密中的ssh密钥。这样,就不需要手动步骤。
$ minikube start --mount-string="$HOME/.ssh/:/ssh-directory" --mount
While reproducing this on ubuntu I encountered  the exact issue. 

The directory was indeed looked like mounted but the files were missing which lead me to think that this is a general issue with mounting directories with docker driver.

There is open issue on github about the same problem ( mount directory empty ) and open feature request to mount host volumes into docker driver.

Inspecting minikube container shows no record of that mounted volume and confirms information mentioned in the github request that the only volume shared with host as of now is the one that mounts by default (that is
/var/lib/docker/volumes/minikube/_data
mounted into minikube's
/var
directory).

$ docker inspect minikube
"Mounts": [ 
  { 
    "Type": "volume", 
    "Name": "minikube", 
    "Source": "/var/lib/docker/volumes/minikube/_data", 
    "Destination": "/var", 
    "Driver": "local", 
    "Mode": "z", 
    "RW": true, 
    "Propagation": ""
  }
docker cp  $HOME/.ssh minikube:<DESIRED_DIRECTORY>