【问题标题】:Cannot copy file to Docker container via Spotify Docker Client无法通过 Spotify Docker 客户端将文件复制到 Docker 容器
【发布时间】:2019-03-05 21:25:49
【问题描述】:

我想通过Spotify将文件复制到未运行的容器中-

文件的创建方式类似于 -

File.createTempFile("olb-", "-temp").deleteOnExit().writeText("some text")

当我尝试时:

client.copyToContainer(inputFileProvider.createFile(task.dataToInsert).toPath(), containerId, "/app/asd.json")

我明白了:

Either container 1adbf9c1ee511272bec78a46be08bf9299c317b11cdb176eed986640ac86a38c or path /app/my_json.json not found.

好吧,我在使用RUN touch /app/my_json.json 构建映像时创建了这个文件 下一次运行:

client.copyToContainer(inputFileProvider.createFile(task.dataToInsert).toPath(), containerId, "/app/my_json.json")

导致

{"message":"extraction point is not a directory"}

好的...我尝试了目录

copyToContainer(inputFileProvider.createFile(task.dataToInsert).toPath(), containerId, "/app/")

结果:

{"message":"Error processing tar file(exit status 1): cannot overwrite directory \"/\" with non-directory \"/\""}

"/app" 也一样

任何想法如何通过 Java 客户端将文件复制到 docker 容器中?

【问题讨论】:

    标签: java docker kotlin spotify spotify-docker-client


    【解决方案1】:

    原来我必须创建一个全新的文件夹,然后在其中单个文件并复制该文件夹。

    val dir = Files.createTempDirectory("tem-folder-")
    Files.createFile(dir.resolve("filename")).toFile().writeText("data to write")
    
    val toBeCopied = dir.toFile()
    
    cliend.copyToContainer(toBeCopied.toPath(), "containerId", "targetPath")
    

    【讨论】:

      猜你喜欢
      • 2022-12-28
      • 1970-01-01
      • 2022-01-10
      • 2021-06-24
      • 1970-01-01
      • 2021-06-27
      • 1970-01-01
      • 2014-03-29
      相关资源
      最近更新 更多