Sign inSign up

pak00329/selenium_python_chrome

By pak00329

•Updated almost 2 years ago

Python base with Selenium and Chrome

Image
Web analytics
0

350

pak00329/selenium_python_chrome repository overview

⁠Overview

This Docker image is built on top of the official python:3.11.4 image, designed for applications requiring Python 3.11 with additional support for headless Chrome and ChromeDriver. It is ideal for running web automation, scraping tasks, or browser-based testing within a lightweight, Linux-based container environment.

⁠Key Features

  1. Python 3.11.4: Provides a robust and reliable base for Python applications.
  2. Headless Chrome: Installs the Chromium browser (version 121.0.6167.85), enabling seamless automation and testing without a GUI.
  3. ChromeDriver: Ships with the corresponding ChromeDriver for full compatibility with the installed Chromium version.
  4. Selenium Installs Selenium 4.25.0 for web browsing.
  5. System Dependencies: Includes essential libraries like libgtk-4-1, libnss3, and xdg-utils to support headless browser operations.

⁠Dockerfile Layers Breakdown

  1. Base Image: Starts with python:3.11.4, providing the Python runtime and toolchain.
  2. System Dependencies Installation: Adds critical system libraries and tools via apt-get.
  3. Chromium and ChromeDriver Setup:
  • Downloads and installs Chromium browser.
  • Downloads and sets up ChromeDriver for browser automation.
  1. Selenium Uses pip to install selenium 4.25.0.
  2. Working Directory: Sets /app as the default working directory for running Python scripts.
  3. Entry Point: Uses an environment variable (SCRIPT_NAME) to define the Python script executed at runtime, ensuring flexibility for users.

⁠How to Use

Build the Image:

docker build -t selenium_python_chrome .

Run a Container: Pass your Python script and its dependencies via mounted volumes or during runtime:

docker run -e SCRIPT_NAME=my_script.py -v $(pwd):/app selenium_python_chrome

Requirements File: Ensure you have a requirements.txt file in the /app directory to automatically install dependencies before running your script.

⁠Environment Variables

SCRIPT_NAME: Specify the Python script to execute (e.g., my_script.py). Default entry point automatically installs dependencies and runs the script.

⁠Use Cases

  • Browser automation with Selenium.
  • Data scraping tasks using headless Chromium.
  • Lightweight testing environments for web-based applications.

⁠Extending the Image

You can extend this image by copying your project files and additional dependencies:

FROM selenium_python_chrome
COPY . /app

This will bundle your application directly into the image for easy deployment.

Tag summary

Content type

Image

Digest

sha256:1e1254f85…

Size

649.9 MB

Last updated

almost 2 years ago

docker pull pak00329/selenium_python_chrome