【发布时间】:2020-10-11 18:52:33
【问题描述】:
我是 docker 新手。 我有一个烧瓶应用程序正在我的 docker 容器上运行,该应用程序需要连接到 MongoDB 以执行 CRUD 操作。
但我在 docker 和 localhost 之间存在一些连接问题。容器无法连接到我的本地 MongoDB。
那么来自 docker 容器的可能的烧瓶应用程序连接到本地主机 MongoDB 吗?
我的 Flask 应用程序 MongoDB 配置设置:
cilent = pymongo.MongoClient('127.0.0.1',27017)
我的 Dockerfile 配置:
FROM ubuntu:latest
MAINTAINER Michael Levan
CMD tail -f /dev/null
RUN apt-get update -y && apt-get install -y python3-pip python-dev
EXPOSE 8080
EXPOSE 5000
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip3 install -r requirements.txt
COPY . /app
ENTRYPOINT [ "python3" ]
CMD [ "app.py" ]
【问题讨论】:
标签: mongodb docker flask connection