简体   繁体   English

Streamlit 在使用 Docker 执行时向我显示“欢迎使用 Streamlit”消息

[英]Streamlit showing me "Welcome to Streamlit" message when executing it with Docker

I'm trying to run a Docker container created from this Dockerfile我正在尝试运行从此 Dockerfile 创建的 Docker 容器

FROM selenium/standalone-chrome
WORKDIR /app

# Install dependencies
USER root
RUN apt-get update && apt-get install python3-distutils -y
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py

COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
RUN pip install selenium==4.1

# Copy src contents
COPY /src /app/

# Expose the port
EXPOSE 8501

# Execution
ENTRYPOINT [ "streamlit", "run" ]
CMD ["app.py"]

Building this container is possible, but when I execute the image, I obtain the following message:构建这个容器是可能的,但是当我执行图像时,我得到以下消息:

👋 Welcome to Streamlit!

  If you're one of our development partners or you're interested in getting
  personal technical support or Streamlit updates, please enter your email
  address below. Otherwise, you may leave the field blank.

  Email: 2022-06-06 09:20:27.690 

And, therefore, I am not able to press enter and continue the execution, as the execution halts.因此,当执行停止时,我无法按 Enter 键并继续执行。 Do you guys know how should I make my Dockerfile to directly execute the streamlit run command and surpass this problem?你们知道我应该如何让我的 Dockerfile 直接执行streamlit run命令并克服这个问题吗?

That welcome message is displayed when there does not exist a ~/.streamlit/credentials.toml file with the following content:当不存在具有以下内容的~/.streamlit/credentials.toml文件时,将显示该欢迎消息:

[general]
email=""

You can either create the above file ( .streamlit/credentials.toml ) within your app directory and copy its content to the container image in your Dockerfile or create this file using RUN commands on the following:您可以在您的应用程序目录中创建上述文件 ( .streamlit/credentials.toml ) 并将其内容复制到 Dockerfile 中的容器映像,或者使用以下运行命令创建此文件:

mkdir -p ~/.streamlit/
echo "[general]"  > ~/.streamlit/credentials.toml
echo "email = \"\""  >> ~/.streamlit/credentials.toml

I would suggest the former approach to reduce the number of layers and thereby reduce the final image size.我建议使用前一种方法来减少层数,从而减小最终图像的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM