bass icon indicating copy to clipboard operation
bass copied to clipboard

Using bass behind a proxy: pulling buildkit image with docker setup

Open pfiaux opened this issue 2 years ago • 0 comments

Displayed error message It's not really a bug and the error is kinda cryptic although I know what the issues I would like to discuss if there are options beyond the error message to make this easier to use.

error	failed to pull buildkit image	{
  "version": "v0.10.3",
  "error": "exit status 1",
  "output": "Error response from daemon: Get \"https://registry-1.docker.io/v2/\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)\n"
}
init buildkit runtime for platform os=linux, arch=any: 
list buildkit workers:
failed to list workers:
Unavailable: connection error: desc = "transport: Error while dialing dial unix /run/buildkit/buildkitd.sock:
connect: no such file or directory"

(line breaks mine for readability)

To Reproduce This is not a fun one to reproduce...

# Setup a proxy
# Setup a firewall that drops all out going traffic not using the proxy
# Join the network using this firewall
# Make sure the computer has Docker Desktop installed (macOS)
bass

After a while the error message above will likely be shown because when bass fails to pull an image without using the proxy.

Other relevant notes:

  • Nothing prints for a while then the error (not clear that bass is actually trying to start a buildkit server to talk to)
  • This is with the proxy settings disabled in docker
  • If the proxy settings are enabled in docker and point to the proxy the image can be pulled
    • There is a bug in Docker Desktop: it does not respect no_proxy so if the proxy is enabled everything is wrongly proxied
    • I have to leave the proxy disabled in Docker Desktop because I need access to an internal registry that is not proxied
    • Toggling the proxy settings on or off on a mac requires a restart of the whole Docker Desktop engine which is slow

Suggested message What would have helped you identify the root cause quicker?

# maybe before the error a hint about no buildkit detected, fetching `basslang/buildkit` (from dockerhub)

Unable to fetch `basslang/buildkit` to start a buildkit instance:
  request canceled while waiting for connection
  (Client.Timeout exceeded while awaiting headers)
  to https://registry-1.docker.io/v2

Make sure xyz or try to manually setup a bass buildkit server according to xyz* (see discussion below)

Beyond the error to resolve the problem I can think of 2 things:

  • A working proxy configuration (ideally respecting no_proxy)
  • Overriding the registry url

I'm not sure it's possible to override docker's pull settings dynamically so probably not much can be done about the first for Docker Desktop.

The second however would at least in some cases solve the problem. If a private registry is available internally (without proxy), prefixing the image name with another url than https://registry-1.docker.io/v2/ would allow using a mirror (also nice to avoid hitting rate limitations from docker hub). Do you think adding something like DEFAULT_IMAGE_REGISTRY_URL would be possible? At least for the buildkit image, perhaps it can be used for scripts after that if the url is not provided as well.

pfiaux avatar Aug 27 '22 09:08 pfiaux