Reputation: 33
neo4j is hosted on cloud and is running in port 11004
, another container that has the application is ready deployed and port 5000
is exposed so that the application can be accessed via browser.
the problem is, the application inside the container need to retrieve data from the running database.
what is to be done?
in the web application:
driver = GraphDatabase.driver("bolt://localhost:11004", auth=("neo4j","1234"))
tried with http ports too,
FROM python:3.7
# Mount current directory to /app in the container image
VOLUME ./:app/
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
# Copy local directory to /app in container
# Dont use COPY * /app/ , * will lead to lose of folder structure in /app
COPY . /app/
# Change WORKDIR
WORKDIR /app
# Install dependencies
# use --proxy http://<proxy host>:port if you have proxy
RUN pip install -r requirements.txt
# In Docker, the containers themselves can have applications running on ports. To access these applications, we need to expose the containers internal port and bind the exposed port to a specified port on the host.
# Expose port and run the application when the container is started
RUN echo
ENTRYPOINT ["python"]
CMD ["app.py"]
EXPOSE 5000
i need the application to fetch data via the neo4j
database available through 11004
port and the results of the webpage via 5000
Upvotes: 1
Views: 286
Reputation: 436
To run the image and to get the container to access the neo4j running on host (by default the network is set to bridge that has to be changed to host for it to access the neo4j running in the host system)
Sudo docker run -p 5000:5000 --network=host
Upvotes: 2
Reputation: 4052
Application hosted in the first container is searching for neo4j within itself (calling neo4j within the container) but neo4j is hosted on another container, so it will not work as the first container don't have neo4j hosted inside it.
You need to link the neo4j hosted container
to the application container
.
You can read more about linking containers here
Upvotes: 1