How to configure proxy in selenium/standalone-chrome docker image using my docker-compose

Viewed 9545

I am using this docker image:

In my docker-compose:

version: '3'
services:
  # Other services ...

  selenium_grid:
    image: selenium/standalone-chrome:4.0.0-beta-3-20210426
    volumes:
      - /dev/shm:/dev/shm
    environment:
      - SE_NODE_SESSION_TIMEOUT=30
      - SE_NODE_MAX_SESSIONS=5
      - SE_NODE_OVERRIDE_MAX_SESSIONS=true
    ports:
      - 4444:4444
      - 7900:7900

I would like to set a proxy url, I see in the documenation of the image this is possible through build_args:

But as I understand this means that I have to clone the image repo, download it, build it and allocate the new version so I can use it in my docker-compose? It has to be other way.

How can I configure a proxy in selenium/standalone-chrome through my docker-compose configuration?

1 Answers

Using the environment http_proxy worked for me:

version: '3'
services:
  selenium_grid:
    image: selenium/standalone-chrome:4.0.0-beta-3-20210426
    #... other config ...
    environment:
      - http_proxy=75.104.15.119:8080

Test:

> docker-compose exec selenium_grid curl http://httpbin.org/ip 
{
  "origin": "75.104.15.119"
}
Related