skip to Main Content

So the problem is this:
When opening some websites (e.g. https://iamstripes.com – most of the urls load correctly, this is a example that doesn’t) in a docker image, the webpage is not rendered correctly and clearly there is some JavaScript missing from the page.

If the same website is opened in local browser, then everything is loaded correctly.

I’ve tried multiple docker images, from selenium based, "simple" docker images only with browser and even sause labs instances and all of them with the same result.

My first assumption is that I’m missing some sort of flag when starting the browser, but I’ve tried (almost) everything suggested in the interwebs without success 🙁

TL;DR
Browser (chrome, firefox) launched in docker fails to open the URL correctly
Browser (chrome, firefox) launched locally opens the URL correctly

example docker image:

docker run -d --name=firefox -p 5800:5800 -v /docker/appdata/firefox:/config:rw jlesage/firefox

and then you can open the docker browser using http://localhost:5800 in any browser window

Several browser options I tried when launching the browser in a docker selenium (missing some here):

--disable-security
--no-sandbox

Also in Chrome capabilities:
excludeSwitches: ["enable-automation"]

I’ve tried with and without these settings, and in the case of Firefox even went directly into the browser about:config and changed some security parameters there directly as well, without success.

2

Answers


  1. Chosen as BEST ANSWER

    For anyone coming across this question with similar problems...

    Default user agent includes references to Apple and Safari, and for some reason the website is enabling features that Chrome and Firefox simply do not support and fail to load the content correctly. That said, if you send the flag:

    --user-agent=Chrome
    

    Then the site will load correctly without any issue...


    1. Might be a problem with the host machine’s network settings.
    2. Docker container has a different network config, hence launch the docker container with the --name=firefox --net=host to the docker command.
    3. Setup the DNS server manually in the docker container but add the --dns=<dns_ip> to the docker command.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search