You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker容器中启动Streamlit应用时能否自动打开浏览器?

问题描述

在无Docker容器的环境中,执行streamlit run app.py命令后,Streamlit会自动打开浏览器标签页加载应用,但在容器中运行时该功能失效。即便遵循官方文档配置,仍需手动访问http://0.0.0.0:8501或http://localhost:8501才能打开应用。

Dockerfile内容
FROM python:3.10-slim
LABEL maintainer="Steven Herrera stevenherrera46375@utexas.edu"

WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl
RUN mkdir /app/.streamlit && mkdir /app/resources

COPY ./docker_requirements.txt /app/docker_requirements.txt
COPY ./.streamlit/config.toml /app/.streamlit/config.toml
COPY ./resources/video_library_favicon.png /app/resources/video_library_favicon.png

RUN pip install --no-cache-dir pip==23.3.1 && pip install --no-cache-dir -r /app/docker_requirements.txt

EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

COPY app.py /app/app.py
# streamlit will say you can view the app at http://0.0.0.0:8501 
# but you actually need to use 127.0.0.1:8501 or localhost:8501 in your browser
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
构建与运行命令
  • 构建镜像命令:
docker build -t youtube-comment-microservice .
  • 运行容器命令:
docker run -p 8501:8501 youtube-comment-microservice

内容的提问来源于stack exchange,提问作者steveh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 20:32:37