0

willnorris/imageproxy is a caching image proxy server that we use in one of our deployments. We typically have a PHP backend that will serve some html or json to a client where the URL would be http://<imageproxy>/200/https://willnorris.com/logo.jpg. Then the client will fetch that image from the proxy. This is fine.

What I cannot get working is doing this in local development using Docker (Compose). The problem is that, unlike production, the domain I want to fetch images from is running on the host, typically only exposed on the loopback interface (127.0.0.*). I typically define an entry in my /etc/hosts folder that is something like

127.0.0.2 web.myproj admin.myproj cdn.myproj

And then I access web.myproj on that computer. How would I get the Docker container to connect to the localhost address of its host (whatever this is called in Docker lingo)? I suppose I can use the extra_hosts feature somehow?

If specifically connecting to a reserved loopback address/localhost is not possible/permitted, is there another way to access an ip of the host?


Tech details

  • Host: Ubuntu 21.04 running inside a VMWare Workstation on Windows 10 Pro
oligofren
  • 601
  • 2
  • 8
  • 21
  • Is this Docker running on WSL2 or on an actual Linux machine? – Michael Hampton Sep 28 '21 at 23:38
  • It's normally running on macOS and "real" Linux when developing. – oligofren Sep 29 '21 at 07:48
  • Do you mean a Linux virtual machine? – Michael Hampton Sep 29 '21 at 09:10
  • No, I switch workstations :) At work I have a Windows computer where I run Linux in a VM (and WSL2, for that matter, but not all apps work equally well) and at home I run macOS. – oligofren Sep 29 '21 at 09:27
  • This is technology, not magic, and as such I can't read either your computer or your mind. It's best to be as detailed as possible when answering such questions, so that people tryiing to help you are not confused by relevant information being missing, nor taking up unnecessary time trying to ask for clarification. That said, here are my questions for clarification: Do you mean that you connect to the Linux VM at work when using macOS at home? What about WSL2? Which one (or both) are you actually using here for this project? – Michael Hampton Sep 29 '21 at 09:40
  • Sure, totally understand that. I was not trying to offend you in any way. I'll scope the question down to Linux. Details added now :) – oligofren Sep 29 '21 at 10:59

0 Answers0