Skip to content

Copy file out from a container #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

evenh
Copy link

@evenh evenh commented Feb 1, 2021

Adds support for copying files out of containers via an io.Reader. I really need this functionality for a project that I'm working on, so I thought the quickest option was to fix it upstream. If this PR looks OK, I would love a new release 🙏🏻

@@ -337,6 +337,29 @@ func (c *DockerContainer) CopyFileToContainer(ctx context.Context, hostFilePath
return c.provider.client.CopyToContainer(ctx, c.ID, filepath.Dir(containerFilePath), buffer, types.CopyToContainerOptions{})
}

func (c *DockerContainer) CopyFileFromContainer(ctx context.Context, containerFilePath string) (io.Reader, error) {
r, _, err := c.provider.client.CopyFromContainer(ctx, c.ID, containerFilePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should r defer r.close ?

@gianarb
Copy link
Member

gianarb commented Mar 31, 2021

Hello!! Thanks a lot for your contribution! But I can't merge it without any unit test

@mdelapenya
Copy link
Member

Hi @evenh I think this was implemented in #347, although not released yet.

If you agree, feel free to close it, and thanks for your patience

@evenh
Copy link
Author

evenh commented Oct 2, 2021

Thanks for tetting back to me. That looks perfect, I'll close this PR 👌🏻

@evenh evenh closed this Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants