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
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:
Then the site will load correctly without any issue...
--name=firefox --net=host
to the docker command.--dns=<dns_ip>
to the docker command.