Skip to content

Support locally built images with Docker::Image.get fallback in #start #78

Description

@dieter-medium

Hi there 👋,

Thanks for the great work on testcontainers-ruby!

Currently, the #start method internally uses:

`Docker::Image.create(...)´

This approach always tries to pull the image from a remote registry, which can be problematic when I’ve built an image locally using:

image_name = "my-name:latest"
Docker::Image.build_from_dir('.', { "t" => image_name, "dockerfile" => "Dockerfile" })

n such cases, it would be helpful if #start could attempt to use Docker::Image.get(image_name) first to find a local image, and only fall back to Docker::Image.create(...) if it's not found.

Proposed logic:

begin
  image = Docker::Image.get(image_name)
rescue Docker::Error::NotFoundError
  image = Docker::Image.create('fromImage' => image_name)
end

Alternatively — or even better — maybe the project could support building an image natively from a local Dockerfile as part of the container lifecycle setup? This would make local development more seamless and reduce external dependencies for custom containers.

Would you be open to adding this fallback behavior?

Thanks again

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions