-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
feat: get container image #1912
feat: get container image #1912
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @FedericoAntoniazzi, thanks for taking the time for your contribution. I'd like to understand more about your use case, as the Image of a container can be obtained from the container request that originated it (unless there is a process modifying it). Could you elaborate a little bit more if possible? |
Thank you for your response @mdelapenya, let me try to explain my use case: |
Hi @FedericoAntoniazzi thanks for the explanation. We are exposing a Docker client in order to do this kind of things: ctx := context.Background()
client, err := testcontainers.NewDockerClientWithOpts(ctx)
if err != nil {
// ...
}
defer client.Close()
// c is the Docker container instance
inspect, err := client.ContainerInspect(ctx, c.ID)
if err != nil {
// ...
}
// Do whatever you need with the ContainerJSON here I'd advise against adding a new method to the interface given the simplicity of the above solution, thanks to the client. But I'd like to listen to your thoughts before closing this one. |
Hi @mdelapenya, I apologize for my late reply. Basically I've already implemented the proposed solution but I noticed the implementation on the library is way simpler both for implementation code and the interface for developers. I also acknowledge the feature I implemented is an edge case or even out of scope for the library, so we can close this PR |
Thanks for your sensitivity, please feel free to send more contributions if you see them feasible 🙏 I'm closing this PR now Cheers! |
What does this PR do?
As per the
testcontainers.Container.Name
method, allow retrieving the image from atestcontainers.Container
interface.The function has been named
ContainerImage
sinceImage
clashes with the Container struct field.Why is it important?
I'm using it on a project to retrieve images from containers running in a docker host and I use testcontainers-go to create containers for a testing environment.
Related issues
No related issues.
How to test this PR
This PR works exactly like
Container.Name()
method, which hasn't been tested, probably because it mainly uses external dependencies.