I am doing a headless scraping with selenium and trying to create a docker image to deploy my script on cloud run. Below is my dockerfile, when I run it I am getting this error
**”message”: “Message: session not created: Chrome failed to start: exited normally.n (session not created: DevToolsActivePort file doesn’t exist)n (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
**
# Use the official Python base image
FROM python:3.10
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
ENV DISPLAY=:99
ENV GOOGLE_APPLICATION_CREDENTIALS=/app/credentials.json
RUN pip install --no-cache-dir chromedriver-py -r requirements.txt
RUN apt-get update && apt-get install -y wget unzip &&
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&
apt install -y ./google-chrome-stable_current_amd64.deb &&
rm google-chrome-stable_current_amd64.deb &&
apt-get clean
CMD [ "python", "app.py" ]
I tried running the container with docker run –shm-size=2g -p 8080:8080, to increase the shared memo size but still same error.
Afsheen Qasim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.