I’m new to docker. I have the one flask app was running on my docker container and the application needs to connect to MongoDB for the CRUD action.
but I have some connection problems between the docker and the localhost. The container cannot connect to my localhost MongoDB.
So is a possible flask app from docker container connect to the localhost MongoDB?
My Flask app MongoDB config setup:
cilent = pymongo.MongoClient('127.0.0.1',27017)
My Dockerfile config:
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" ]