Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug: WithUseLocalImagesFirst() doesn't work with local only images #795

Closed
Omar-V2 opened this issue Jan 31, 2023 · 2 comments · Fixed by #798
Closed

Bug: WithUseLocalImagesFirst() doesn't work with local only images #795

Omar-V2 opened this issue Jan 31, 2023 · 2 comments · Fixed by #798
Assignees

Comments

@Omar-V2
Copy link

Omar-V2 commented Jan 31, 2023

Describe the bug
Trying to create a container from a local image (one that is not hosted on any container registry) doesn't work when using WithUseLocalImagesFirst().

To Reproduce
Repo: https://github.com/Omar-V2/temporal-coffeeshop/blob/main/internal/customer/integration-tests/customer/customer_test.go

  1. Build docker image from local dockerfile and tag it with a name. For example from the root of this repo run the following:
    docker build -f internal/customer/Dockerfile.worker -t customer-worker .

  2. Execute the integration test here
    go test -v -run ^TestCustomerServiceIntegrationTestSuite internal/customer/integration-tests/customer/customer_test.go. Which attempts to start the container from the image as follows

s.temporalWorker, err = gnomock.StartCustom(
  "customer-worker",
  gnomock.DefaultTCP(8082),
  gnomock.WithUseLocalImagesFirst(),
  gnomock.WithDebugMode(),
  gnomock.WithEnv(fmt.Sprintf("TEMPORAL_ADDRESS=%s", s.temporalServer.DefaultAddress())),
)
  1. The local container is not found and I keep getting the error:
              Error:          Received unexpected error:
                                can't start container: can't prepare container: can't pull image: can't pull image: Error response from daemon: pull access denied for customer-worker, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Expected behavior
I expected the container to be created from the local image - however it seems that the container is not even found. After some digging around in gnomock's source code I discovered the function isExistingLocalImage and after some debugging I realise it's expecting an image named library/customer-worker which Im not sure why it expects it to be named like this? I notice it's using strings.HasSuffix(image, repoTag) - are these parameters the wrong way round? For example, if my image is named "customer-worker:latest" repoTag will be "library/customer-worker:latest" and so strings.HasSuffix(image, repoTag) will always return false - unless the parameters are swapped then this would make sense?

Anyway, as a workaround I tried naming my image "library/customer-worker" and this did indeed allow it to be discovered however now I get a different error

                Error:          Received unexpected error:
                                can't start container: container network isn't ready: can't inspect container 5e93d9b5f5eec2764bec9a9aeb92127b58fcd6403fccb3cb48998468248ba342: Error: No such container: 5e93d9b5f5eec2764bec9a9aeb92127b58fcd6403fccb3cb48998468248ba342

Screenshots
If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: Mac OS Ventura
  • Version: 13.1
  • Docker version: 20.10.21, build baeda1f

Additional context
Add any other context about the problem here.

@claraisrael
Copy link

I'm experiencing a very similar issue. Any leads would be highly appreciated. @orlangure

@orlangure
Copy link
Owner

Hi @Omar-V2, @claraisrael 😼
Thank you for your reports.

Can you try the fix from #798? With it I managed to create a container using a local image without adding library/ or version tag. I'll wait for your feedback a couple of days before merging it.

@orlangure orlangure self-assigned this Feb 2, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants