DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Tools
  4. A Gotcha With Running Neo4j 3.2 With APOC in Docker

A Gotcha With Running Neo4j 3.2 With APOC in Docker

With the release of Neo4j 3.2, a little gotcha was introduced if you're running APOC with Neo4j in Docker. See what exactly that gotcha is and how you can deal with it.

Stefan Armbruster user avatar by
Stefan Armbruster
·
May. 18, 17 · Tutorial
Like (2)
Save
Tweet
Share
4.68K Views

Join the DZone community and get the full member experience.

Join For Free

Neo4j 3.2.0 was released last week at GraphConnect Europe. Among lots of cool new features, unfortunately, it has one new “feature” making the lives of APOC users little bit harder, especially if you run Neo4j from Docker. 

Background

Since 3.0, you've been able to enrich Cypher with your own stored procedures. Those are written in Java (or any other JVM language) and get deployed to the /plugins folder. In 3.1, user-defined functions were added, followed by aggregate functions in 3.2.

All of them use annotations like @Context GraphDatabaseService db to retrieve a reference to the database itself. For getting deeper into Neo4j’s machinery room, one could have @Context GraphDatabaseAPI api to allow you full access. This full access can be abused to break out of the permissions system added in 3.1.

Therefore, in 3.2, all procedures and functions run in a sandboxed environment disallowing potentially harmful dependencies like GraphDatabaseAPI from being injected. Using a config option dbms.security.procedures.unrestricted=<procedure names> , you can deactivate the sandboxing for a given list of procedures. This config option also allows wildcards like *.

A couple of procedure/functions in APOC depend on using internal components and therefore need to be added as unrestricted procedures. This can be achieved by using apoc.* as a value for this config option.

In a regular (AKA non-Docker) deployment, you would just adopt conf/neo4j.conf with that setting.

And Docker?

When starting a Neo4j docker container, you can dynamically amend config settings using -e. Everything starting with -e NEO4J_<configKey>=<convifgValue> will be amended to the config file. Be aware that dots need be rewritten with an underscore. 

There's a gotcha! Trying to use -e NEO4J_dbms_security_procedures_unrestricted=apoc.* does not work since the shell expands the wildcard * with all file in current directory. Even apoc.\* doesn’t help. I suspect docker internally tries another expansion. What I found finally working is using three backslashes: -e NEO4J_dbms_security_procedures_unrestricted=apoc.\\\*

My typical Docker command for firing up a throw-away database to be used for demos and trainings typically looks like this:

docker run --rm -e NEO4J_AUTH=none \
   -e NEO4J_dbms_security_procedures_unrestricted=apoc.\\\* \
   -v $PWD/plugins:/plugins \
   -p 7474:7474  -p 7687:7687 neo4j:3.2.0-enterprise

Of course, the APOC JAR file needs to reside in plugins folder of the directory where the command is fired from. 

Docker (software) Neo4j

Published at DZone with permission of Stefan Armbruster, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Choosing the Right Framework for Your Project
  • Public Key and Private Key Pairs: Know the Technical Difference
  • How Chat GPT-3 Changed the Life of Young DevOps Engineers
  • Master Spring Boot 3 With GraalVM Native Image

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: