我有一个流线型应用程序(localhost:8501)
和一个 API (127.0.0.1:8000)
。
我的 streamlit 应用程序尝试访问 API。
当我启动命令以启动“streamlit”时,它运行良好。但是当 streamlit 在 Docker 容器中时,我无法访问 URL。我有这个错误:
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /predict (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f2a5ebae090>: Failed to establish a new connection: [Errno 111] Connection refused'))
这是我的码头文件:
FROM tiangolo/uvicorn-gunicorn:python3.7
ENV PYTHONPATH .
RUN mkdir /streamlit
COPY requirements.txt /streamlit
WORKDIR /streamlit
RUN pip install -r requirements.txt
COPY . /streamlit
EXPOSE 8501
CMD ["streamlit", "run", "web/source/web_api.py"]
我启动的命令:
docker build --tag web_streamlit.
docker run --publish 8501:8501 --detach --name web_streamlit_container web_streamlit