Skip to content

Instantly share code, notes, and snippets.

@ppdouble
Created April 29, 2022 15:35
Show Gist options
  • Save ppdouble/955ca8ea2391473e11c000ebd7b8c200 to your computer and use it in GitHub Desktop.
Save ppdouble/955ca8ea2391473e11c000ebd7b8c200 to your computer and use it in GitHub Desktop.
Neo4j in docker
CUSTOMIZE_FOLDER=/home/software/neo4j/mygraphdb/
docker run \
--name mygraphdb \
--publish=7474:7474 --publish=7687:7687 \
--detach \
--volume=$CUSTOMIZE_FOLDER/data:/data \
--volume=$CUSTOMIZE_FOLDER/conf:/var/lib/neo4j/conf \
--volume=$CUSTOMIZE_FOLDER/logs:/logs \
--volume=$CUSTOMIZE_FOLDER/import:/import \
--volume=$CUSTOMIZE_FOLDER/plugins:/plugins \
--env NEO4J_AUTH=neo4j/MyGraphPass \
--env NEO4J_dbms_memory_pagecache_size=1G \
neo4j:latest
@ppdouble
Copy link
Author

--volume=$CUSTOMIZE_FOLDER/data:/data
Mapping folder /data in container to folder $CUSTOMIZE_FOLDER/data in local host

@ppdouble
Copy link
Author

docker exec --interactive --tty mygraphdb bash Access the neo4j container

@ppdouble
Copy link
Author

ppdouble commented Apr 30, 2022

Because the -v and --volume flags have been a part of Docker for a long time, their behavior cannot be changed. This means that there is one behavior that is different between -v and --mount.

If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory.

If you use --mount to bind-mount a file or directory that does not yet exist on the Docker host, Docker does not automatically create it for you, but generates an error.

Example:

 docker run --detach \
  --interactive \
  --name devtest \
  --volumes="$(pwd)"/target:/app \
  nginx:latest
docker run --detach \
  --interactive \
  --name devtest \
  --mount type=bind,source="$(pwd)"/target,target=/app \
  nginx:latest

DOC differences-between--v-and---mount-behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment