$ docker exec -ti myname-neo4j bin/neo4j-admin dump --database=graph.db --to=/home/name/myname.dump
command failed: the database is in use -- stop Neo4j and try again
However, if the Neo4j process is stopped, which seems to be the only way to free the database, the container closes. This appears to be the expected behavior from Docker. Therefore, it appears to be impossible to call neo4j-admin dump from within the container without the database being in use.
How can this be resolved while still using Docker?
Then you can either keep the "dump" container and reuse it, or just remove it. Same concept with the entrypoint and -c parameter would apply for the load procedure.
By coincidence it's now much easier to do this in Neo4j 4.0 because you can stop and start databases without having to shut down the whole Docker container.
So if we wanted to take a dump of a database called 'foo', we'd do the following: