Neo4j 在后台运行,即使 Docker 容器未运行。

huangapple go评论68阅读模式
英文:

Neo4j process running in background even when the docker container isn't running

问题

我正在处理我的项目,其中我正在使用Neo4j Docker镜像。我从这里拉取了镜像:https://hub.docker.com/_/neo4j。问题是,即使在停止容器后,neo4j进程仍然在运行。所以当我运行docker start neo4j_db时,它不会启动,当我检查日志时,它会显示:

通过使用docker inspect,我发现它最初运行的命令是tini -g -- /startup/docker-entrypoint.sh neo4j。我想停止这个全局的neo4j进程,这样在运行docker start neo4j_db时,我可以在浏览器上使用它,地址是http://localhost:7474

我对neo4j还很陌生,所以我不知道如何继续。任何帮助都将不胜感激。

更新:
我采取的步骤顺序:

1. docker pull neo4j
2. docker run --name neo4j_db --publish=7474:7474 --publish=7687:7687 --volume=./neo4j:/neo4j/data -itd neo4j
3. docker stop neo4j_db # 每当我想要停止容器时
4. docker start neo4j_db # 每当我想要启动容器时

此外,我还没有任何Docker文件。一旦我有一个容器,我只需启动/停止它以便将来使用。

英文:

I'm working on my project for which I'm using Neo4j docker image. I pulled the image from here: https://hub.docker.com/_/neo4j. The problem is the neo4j process continues to run even after stopping the container. So when I run docker start neo4j_db, it doesn't start, and when I check the logs, it says:

Neo4j is already running (pid:7).
Run with '--verbose' for a more detailed error message.
Neo4j is already running (pid:7).
Run with '--verbose' for a more detailed error message.

By using docker inspect, I found out that the initial command it runs is tini -g -- /startup/docker-entrypoint.sh neo4j. I want to stop this global neo4j process so that on running docker start neo4j_db, I can use it on the browser at http://localhost:7474.

I'm new to neo4j, so I don't know how to proceed. Any help is much appreciated.

Update:
The sequence of steps I took:

 1. docker pull neo4j
 2. docker run --name neo4j_db --publish=7474:7474 --publish=7687:7687 --volume=./neo4j:/neo4j/data -itd neo4j
 3. docker stop neo4j_db # whenever I want to stop the container
 4. docker start neo4j_db # whenever I want to start the container

Also, I don't have any dockerfile yet. Once I've a container, I just start/stop it to use it in future.

答案1

得分: 1

正如评论中已经提到的,杀死容器比停止它们更正常。由于neo4j是一个数据库,您需要特别确保没有任何闲置的容器仍在运行并写入您的数据,从而导致数据损坏。

为了使您的数据在容器之间保持持久,将您的数据文件夹挂载到 /data 而不是 /neo4j/data

如果您将其挂载到 /data,那么neo4j将自动将所有内容写入那里,您可以在将来的容器中使用相同的数据继续上一个容器停止的地方。

对于您的示例,这意味着您应该执行以下操作:

docker kill neo4j_db
docker run -itd \
--name neo4j_db \
--publish=7474:7474 \
--publish=7687:7687 \
--volume=./neo4j:/data \
neo4j
英文:

As was already said in the comments, it's more normal to kill containers than to stop them. Since neo4j is a database, you want to be extra sure that there aren't any stray containers still running and writing to your data causing data corruption.

To have your data persist between containers,
mount your data folder to /data not /neo4j/data.
If you mount it to /data, then neo4j will automatically write everything there and you can use the same data in future containers to continue on where the last one left off.

For your example that all means you should be doing:

docker kill neo4j_db
docker run -itd \
--name neo4j_db \
--publish=7474:7474 \
--publish=7687:7687 \
--volume=./neo4j:/data \
neo4j

huangapple
  • 本文由 发表于 2023年6月8日 01:27:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425752.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定