大网数据广告活动
服务器运维问答

How do you perform a dump of a Neo4j database within a Docker container?

· 52CE 我爱测

A docker container for Neo4j is started as per the documentation and working properly using the following command: $ docker run \ --detach \ --publish=7474:7474 \ --publish=7473:7473 \ --publish=7687:7687 \ --volume=$HOME/neo4j/d…

问题原文

原帖链接 · Gregyski · CC BY-SA 3.0

A docker container for Neo4j is started as per the documentation and working properly using the following command:

$ docker run \
    --detach \
    --publish=7474:7474 \
    --publish=7473:7473 \
    --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    --volume=$HOME/neo4j/logs:/logs \
    --volume=$HOME/neo4j/ssl:/ssl \
    --ulimit=nofile=40000:40000 \
    --name=myname-neo4j \
    neo4j:3.1.1

When I attempt to perform a neo4j-admin dump of the database I get an error:

$ 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?

已采纳解答

原帖链接 · Juan · CC BY-SA 3.0

1: Stop the container.

docker stop myname-neo4j

2: Remove the container

docker rm myname-neo4j

3: Run the container as interactive mode (-it) without the option (detach) and executing the shell ( /bin/bash ).

docker run \
--publish=7474:7474 \
--publish=7473:7473 \
--publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--volume=$HOME/neo4j/ssl:/ssl \
--ulimit=nofile=40000:40000 \
--name=myname-neo4j \
-it \
neo4j:3.1.1 \
-c /bin/bash

Now you are inside the neo4j container without running Neo.

4: Check that neo is not up by visiting the URI endpoint in (http://yourhost:7474). You should see the "Unable to connect" message.

5: Dump your database

docker exec -ti myname-neo4j bin/neo4j-admin dump --database=graph.db --to=/home/name/myname.dump

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。