1

I am running a local instance of my webapp on my machine and am trying to access it from within a docker container. My docker container contains my testframework using selenium.

Usually this wouldn't be a problem when the app is accessible via localhost and using host.docker.internal, but the webapp is using a proxy by webpack-devserver:

    devServer: {
        hot: true,
        port: 6555,
        proxy: [
            {
                context: ['/api/**', '/public/**'],
                target: 'http://myapp:5555'
            }
        ]
    }

I am able to access any other website from within the container, only http://myapp:6555 produces "This site can't be reached". Accessing http://myapp:6555 from the hostmachine works.

This is my docker-compose:

    version: "3.4"
    services:
      hub:
        image: selenium/hub:latest
      chrome:
        image: selenium/node-chrome
        shm_size: '2gb'
        depends_on:
          - hub
        environment:
          - HUB_HOST=hub
          - HUB_PORT=4444
      test:
        image: testframework:latest
        shm_size: '2gb'
        depends_on:
          - chrome
        environment:
          - URL=http://myapp:6555

The search only showed solutions for either when both applications are in a docker container or when the webapp is not using a proxy. Unfortunately both are not an option for me.

nerdycity
  • 11
  • 1
  • Replace my app with the localip of the host mechine eg https://192.178.1.2:65555 – PDHide Jan 14 '21 at 20:24
  • I am still getting the same error when using the IP. Could a VPN affect this? Both (Docker and Webapp) run on the same machine. – nerdycity Jan 14 '21 at 21:31
  • firewall might affect it – PDHide Jan 14 '21 at 21:43
  • Do you mean that http://myapp:5555 works from your host machine? Because you have your devServer port running on 6555. So you are trying to proxy container:6555 to host:5555? Also, you shouldn't need the ** in your proxy context. – Terry Sposato Jan 15 '21 at 03:28
  • From my hostmachine I can only access myapp:6555. Myapp:5555 shows "Not found". Interestingly though, I see the same "Not found" error from my container using http://:5555, so I am not sure if it's a firewall issue – nerdycity Jan 15 '21 at 15:44

0 Answers0