无法将 Python 应用与 Docker 容器化

Can't containerise Python app with Docker

你能帮我解决这个问题吗?

PS 如果这对您有帮助,这是源代码 https://github.com/anatolyRozhkov/RozhkovPetProject.git

我相信您已经在 Dockerfile 中安装了 Google Chrome 浏览器和 Chrome 驱动程序。然后使用命令 docker run <image_name>:latest

在您的容器中构建 docker 图像和 运行 您的 docker 图像
FROM python:3.8

# install google chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable

# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/

# set display port to avoid crash
ENV DISPLAY=:99

RUN pip install selenium
RUN pip install pytest

WORKDIR /app -#python file that u want to run
COPY . /app

CMD ["python", "/tests/form_page/test_form_page.py"]