docker-neo4j
docker-neo4j copied to clipboard
Unexpected behavior running two instances with compose
I am trying to run two instances of neo4j with compose so that I can have one for development and one for testing. I'm finding that I'm able to write to both instances via bolt, but the web ui only shows me results from one of them no matter which port I use.
Here is a docker-compose.yml
file that reproduces this issue:
version: '2.1'
services:
neo4j:
image: neo4j:3.3.3
environment:
- NEO4J_AUTH=none
ports:
- 7474:7474
- 7687:7687
neo4jtest:
image: neo4j:3.3.3
environment:
- NEO4J_AUTH=none
ports:
- 7475:7474
- 7688:7687
Insert a node into the instance listening on 7687:
cypher-shell -a bolt://localhost:7687 "CREATE (:Person {name: 'The Dude'})"
Then go to http://localhost:7474/ and execute the cypher MATCH (n) RETURN n
- it returns this node as expected. However, I can also go to http://localhost:7475/ and execute the same query and it returns the same result - i.e., it is giving me the result that i inserted into the other container.
I can likewise insert a value in to the instance listening on 7688:
cypher-shell -a bolt://localhost:7688 "CREATE (:Person {name: 'Lebowski'})"
That node doesn't show up in either UI.
Is there an "advertised address" confusion going on here? What is the proper setting? I don't know if there's a way to protect anyone from it or maybe there's just some potential documentation improvement, but this does seem like really confusing "default" behavior.
I can confirm this problem on Ubuntu 16.04 with the docker-compose.yml
below:
version: "3"
services:
neo4j-one:
image: neo4j:3.4.0
ports:
- "7474:7474"
- "7687:7687"
privileged: true
environment:
- NEO4J_dbms_security_procedures_unrestricted=apoc.*,algo.*
- NEO4J_apoc_export_file_enabled=true
- NEO4J_apoc_import_file_enabled=true
- NEO4J_dbms_shell_enabled=true
user: $UID:$GID
volumes:
- ./neo4j/neo4j-one/data:/data
- ./neo4j/neo4j-one/plugins:/plugins
- ./neo4j/neo4j-one/logs:/logs
- ./data:/import
container_name: neo4j-one
neo4j-two:
image: neo4j:3.4.0
ports:
- "7475:7474"
- "7688:7687"
privileged: true
environment:
- NEO4J_dbms_security_procedures_unrestricted=apoc.*,algo.*
- NEO4J_apoc_export_file_enabled=true
- NEO4J_apoc_import_file_enabled=true
- NEO4J_dbms_shell_enabled=true
user: $UID:$GID
volumes:
- ./neo4j/neo4j-two/data:/data
- ./neo4j/neo4j-two/plugins:/plugins
- ./neo4j/neo4j-two/logs:/logs
container_name: neo4j-two
Any insight or, if applicable, suggestions would be great.
I had this problem myself:
The browser always connects to the advertised bolt port of the image which means the browser on 7475 still gets advertised the the bolt port of the normal instance (7687). The neo4j instance doesn't know that docker mapped the port to 7688. You can however change this by setting this environment variable: NEO4J_dbms_connector_bolt_advertised__address=:7688