My objective is to scrape the web with selenium driven by python from a docker container.
I've looked around for and not found a docker image with all of the following installed:
- python3
- chromedriver
- chrome
- selenium
Is anyone able to link me to a docker image with all of these installed and working together?
Perhaps building my own isn't as difficult as I think, but it's alluded me thus far.
Any and all advice appreciated.
I've recently updated this image with selenium included versions:
https://hub.docker.com/r/joyzoursky/python-chromedriver/
It uses python3 as base image and install chromedriver, chrome and selenium (as a pip package) to build. I used the alpine based python3 version for myself, as the image size is smaller.
See if the images suit your case, as you could pip install selenium with other packages together by a
requirements.txt
file to build your own image, or take reference from the Dockerfiles of this.If you want to pip install more packages apart from selenium, you could build your own image as this example:
First, in your working directory, you may have a
requirements.txt
storing the package versions you want to install:Then create the Dockerfile in the same directory like this:
Then build the image:
This differs with the selenium official one as selenium is installed as a pip package to a python base image. Yet it is hosted by individual (myself) so may have higher risk of stopping maintenance.
Try https://github.com/SeleniumHQ/docker-selenium.
It has python installed:
The instructions indicate you start it with
Edit:
To allow selenium to run through python it appears you need to install the packages. Create this
Dockerfile
:Then you could run it with
The advantage compared to the plain
python
docker image is that you won't need to install the chromedriver itself since it comes fromselenium/standalone-chrome
.