i have a python script that open the integrated camera when i run it . it works fine but when i put the script in docker container and tries to run i face this error in the log of the container:
Error: Unable to open camera.
i created the container using this command :
docker run --device /dev/video0:/dev/video0 --net=host camera-app
and the cmd log return this error :
docker: Error response from daemon: error gathering device information while adding custom device "/dev/video0": no such file or director.
**this is my dockerfile : **
# Use an official Python runtime as a parent image
FROM python:3.12.2
# Set the working directory in the container to /app
WORKDIR /app
# Install libGL library
RUN apt-get update && \
apt-get install -y libgl1 && \
rm -rf /var/lib/apt/lists/*
# Copy the Python script into the container at /app
COPY camera_access.py .
# Install OpenCV library
RUN pip install opencv-python
# Expose any necessary ports
# (This script doesn't expose any ports, but you can modify this if needed)
EXPOSE 2000
# Run the Python script when the container launches
CMD ["python", "camera_access.py"]
i tried bind mount for /dev/video0 in the dockerfile but it didn't work .
Also i checked the camera index and it's 0 .