在Docker中部署neo4j 后无法 Connect to Neo4j 问题

具体情况

  1. 使用 docker 下载最新的 image: docker pull neo4j
  2. 启动 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
  1. 容器无限重启, 或无法 Connect to Neo4j

解决办法

  1. 去掉--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
  1. 浏览器登录 http://localhost:7474/browser/
  2. Username 和 Password 都填 neo4j
    填写后点击Connect
  3. 输入新的密码即可
    输入新的密码

可能原因:

具体原因不明猜测可能是官方文档中的下面这个原因

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)

OptionDescriptionExample
--nameName your container to avoid generic ID.docker run --name myneo4j neo4j
-pSpecify which container port to expose.docker run -p7687:7687 neo4j
-dDetach container to run in the background.docker run -d neo4j
-vBind mount a volume.docker run -v $HOME/neo4j/data:/data neo4j
--envSet config as environment variables for the Neo4j database.docker run --env NEO4J_AUTH=neo4j/your_password neo4j
--userRun neo4j as the given user, instead of neo4j.docker run --user="$(id -u):$(id -g)" neo4j
--restartControl whether Neo4j containers start automatically when they exit, or when Docker restarts.docker run --restart always
--helpOutput full list of docker run optionsdocker run --help
Mount pointPermissions requiredDescription
/dataread, writeThe data store for the Neo4j database. See Mounting storage to /data.
/logsread, writeOutput directory for Neo4j logs. See Mounting storage to /logs.
/confreadhttps://neo4j.com/docs/operations-manual/current/docker/mounting-volumes/#tnotedef1Pass configuration files to Neo4j on startup.
See Modify the default configuration.
/pluginsreadhttps://neo4j.com/docs/operations-manual/current/docker/mounting-volumes/#tnotedef2Allows you to install plugins in containerized Neo4j.
See Plugins.
/licensesreadProvide licenses for Neo4j and any plugins by mounting the license folder.
See Installing Plugin Licenses.
/importreadMake csv and other importable files available to neo4j-admin import.
/sslreadProvide SSL certificates to Neo4j for message encryption.
See SSL encryption in a Neo4j Docker container
/metricswriteEnterprise Edition Output directory for metrics files. See Metrics
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值