具体情况
- 使用 docker 下载最新的 image:
docker pull neo4j
- 启动 neo4j
docker run --name neo4j-container \
-d \
--detach \
--restart always \
--env NEO4J_AUTH=neo4j/your_password \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--volume=$HOME/neo4j/conf:/conf \
--volume=$HOME/neo4j/import:/import \
neo4j
- 容器无限重启, 或无法 Connect to Neo4j
解决办法
- 去掉
--env NEO4J_AUTH=neo4j/your_password \
启动:
docker run --name neo4j-container \
-d \
--detach \
--restart always \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--volume=$HOME/neo4j/conf:/conf \
--volume=$HOME/neo4j/import:/import \
neo4j
- 浏览器登录
http://localhost:7474/browser/
- Username 和 Password 都填 neo4j
- 输入新的密码即可
可能原因:
具体原因不明猜测可能是官方文档中的下面这个原因
Setting
NEO4J_AUTH
does not override the existing authentication.If you have mounted a /data volume containing an existing database, setting will have no effect because that
database already has authentication configured. The Neo4j Docker
service will start, but you will need a username and password already
associated with the database to log in.NEO4J_AUTH
另外要注意的是, 如果你要挂载的话要先创建好文件夹, 不然也不行, 比如:
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--volume=$HOME/neo4j/conf:/conf \
--volume=$HOME/neo4j/import:/import \
你要确保$HOME/neo4j/data
文件夹已经创建好
The folders that you want to mount must exist before starting Docker,
otherwise, Neo4j fails to start due to permissions errors.
官方文档
Getting started with Neo4j in Docker - Operations Manual
Persisting data with Docker volumes - Operations Manual (neo4j.com)
Option | Description | Example |
---|---|---|
--name | Name your container to avoid generic ID. | docker run --name myneo4j neo4j |
-p | Specify which container port to expose. | docker run -p7687:7687 neo4j |
-d | Detach container to run in the background. | docker run -d neo4j |
-v | Bind mount a volume. | docker run -v $HOME/neo4j/data:/data neo4j |
--env | Set config as environment variables for the Neo4j database. | docker run --env NEO4J_AUTH=neo4j/your_password neo4j |
--user | Run neo4j as the given user, instead of neo4j . | docker run --user="$(id -u):$(id -g)" neo4j |
--restart | Control whether Neo4j containers start automatically when they exit, or when Docker restarts. | docker run --restart always |
--help | Output full list of docker run options | docker run --help |
Mount point | Permissions required | Description |
---|---|---|
/data | read, write | The data store for the Neo4j database. See Mounting storage to /data . |
/logs | read, write | Output directory for Neo4j logs. See Mounting storage to /logs . |
/conf | readhttps://neo4j.com/docs/operations-manual/current/docker/mounting-volumes/#tnotedef1 | Pass configuration files to Neo4j on startup. See Modify the default configuration. |
/plugins | readhttps://neo4j.com/docs/operations-manual/current/docker/mounting-volumes/#tnotedef2 | Allows you to install plugins in containerized Neo4j. See Plugins. |
/licenses | read | Provide licenses for Neo4j and any plugins by mounting the license folder. See Installing Plugin Licenses. |
/import | read | Make csv and other importable files available to neo4j-admin import. |
/ssl | read | Provide SSL certificates to Neo4j for message encryption. See SSL encryption in a Neo4j Docker container |
/metrics | write | Enterprise Edition Output directory for metrics files. See Metrics |