代码之家  ›  专栏  ›  技术社区  ›  Sudhir

将本地文件复制到k8s容器时出错

  •  2
  • Sudhir  · 技术社区  · 8 年前

    我试图通过执行下面的命令将jar文件复制到特定pod的容器中。

    kubectl cp local_policy.jar podname:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/lib/security .

    我正在犯错误。

    rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"tar\\\": executable file not found in $PATH\"\n"
    

    请帮忙。

    2 回复  |  直到 8 年前
        1
  •  2
  •   Ignacio Millán    8 年前

    tar二进制文件是运行cp所必需的。它位于kubectl cp的帮助页面:

    kubectl cp --help
    Copy files and directories to and from containers.
    
    Examples:
      # !!!Important Note!!!
      # Requires that the 'tar' binary is present in your container
      # image.  If 'tar' is not present, 'kubectl cp' will fail.
    
        2
  •  0
  •   Amrut Prabhu    7 年前

    只需安装 tar 要复制文件的容器中的二进制文件。这将允许kubectl命令将文件从本地计算机复制到目标容器。 在Amazon linux上,您可以通过 yum

    yum install tar