jmc jmc - 2 months ago 25
C# Question

Specify bolt port for a neo4j docker container

I have two neo4j containers created using a

docker-compose.yml
file.

version: '2'
services:
neo4jdev1:
image: neo4j
ports:
- "7474:7474"
- "7687:7687"
volumes:
- $HOME/neo4jdev1/data:/data
expose:
- "7687"
- "7474"
neo4jdev2:
image: neo4j
ports:
- "7475:7474"
- "7689:7689"
volumes:
- $HOME/neo4jdev2/data:/data
expose:
- "7689"
- "7475"


When I run this using
docker-compose up
, I get the two services running. I checked those by visiting the following URLS.

https://192.168.99.100:7474


https://192.168.99.100:7475


As you can see I am trying to expose port 7689 for my second service because I want to use it as the port for bolt instead of the default 7687.

In my unit tests, I tried to connect to bolt using both drivers.

Test 1 (using port 7687) - PASS



IDriver driver = GraphDatabase.Driver("bolt://192.168.99.100:7687", AuthTokens.Basic("neo4j", "password"));


Test 2 (using port 7689) - FAIL



IDriver driver = GraphDatabase.Driver("bolt://192.168.99.100:7689", AuthTokens.Basic("neo4j", "password"));


Here's what I have done so far. I edited the config file inside the container located at
/var/lib/neo4j/conf/neo4j.conf
. I changed this line from

dbms.connector.bolt.address=0.0.0.0:7687
to
dbms.connector.bolt.address=0.0.0.0:7689


After saving the config file, the test still fails and the bolt port still shows 7687 in the neo4j browser.

enter image description here

Is there another way to specify the bolt port on the docker-compose file or is there another way to change the bolt port in the running container itself?

Answer

Try:

neo4jdev2:
  image: neo4j
  ports: 
     - "7475:7474"
     - "7689:7687"
  volumes:
     - $HOME/neo4jdev2/data:/data

For the ports part, the first port is the one used outside the container, the second one is used inside the container.