How to setup Selenium Chrome Docker to use HTTP Proxy

As you may know, selenium docker is the main stream way to do a real GUI End-2-End headless testing over Chrome / Firefox. While it really hassled me that the lack of docs to get it work behind corporate http proxy.

After days of trying, I finally featured out the way to get Selenium Chrome Docker (StandaloneChromeDebug) to adopt Oracle Proxy.

Here is the Dockerfile:

FROM selenium/standalone-chrome-debug

ARG https_proxy
ARG http_proxy
ARG no_proxy

ENV https_proxy {https_proxy}
ENV HTTPS_PROXY{https_proxy}

ENV http_proxy {http_proxy}
ENV HTTP_PROXY{http_proxy}

ENV no_proxy {no_proxy}
ENV NO_PROXY{no_proxy}


RUN echo "a2: Got Proxy setting as: {http_proxy}"

RUN echo "http_proxy=\"{http_proxy}\"" >> /etc/environment && \
  echo "HTTP_PROXY=\"{http_proxy}\"" >> /etc/environment && \
  echo "https_proxy=\"{https_proxy}\"" >> /etc/environment && \
  echo "HTTPS_PROXY=\"{https_proxy}\"" >> /etc/environment && \
  echo "no_proxy=\"{no_proxy}\"" >> /etc/environment && \
  echo "NO_PROXY=\"{no_proxy}\"" >> /etc/environment  && \
  echo "ftp_proxy=\"{http_proxy}\"" >> /etc/environment  && \
  echo "FTP_PROXY=\"${http_proxy}\"" >> /etc/environment

docker build script:

  dockerBuildScript="docker build -t SeleniumStandaloneChromeDebug-Proxy-Image"

  if [[ ! -z {https_proxy} ]];then
    dockerBuildScript="{dockerBuildScript} --build-arg https_proxy='{https_proxy}'"

  if [[ ! -z{http_proxy} ]];then
    dockerBuildScript="{dockerBuildScript} --build-arg http_proxy='{http_proxy}'"

  if [[ ! -z {no_proxy} ]];then
    dockerBuildScript="{dockerBuildScript} --build-arg no_proxy='{no_proxy},{assumedSeleniumDockerContainerName}'"

  dockerBuildScript="{dockerBuildScript} -f Dockerfile ."

  eval "{dockerBuildScript}"

Here is the VNC screenshot:


Note that, to let docker pull behind proxy over Oracle Linux 7, you have to set it to service first, just following:"