Neo4J docker-compose cypher-shell:由于身份验证失败而未经授权

问题描述 投票:0回答:1

我正在尝试使用 docker-compose 在 docker 容器中运行我的 neo4j v4.1 数据库。这是我的文件:

docker-compose.yml

services:
  neo4j:
    build: .
    container_name: neo4j
    ports:
      - "7474:7474"  # HTTP port
      - "7687:7687"  # Bolt port
    volumes:
      - ./data:/data
      - ./import:/var/lib/neo4j/import
      - ./plugins:/plugins
    environment:
      - NEO4J_AUTH=neo4j/mypass 
      - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes

Dockerfile

FROM neo4j:4.1-enterprise
# Copy your initialization scripts into the container
COPY scripts /var/lib/neo4j/scripts
RUN chmod +x scripts/entrypoint.sh
ENTRYPOINT ["bash", "/var/lib/neo4j/scripts/entrypoint.sh"]

入口点.sh

#!/bin/bash

# Start Neo4j in the background
neo4j start

# Wait for Neo4j to be ready
echo "Waiting for Neo4j to start..."
sleep 15

echo "Testing cypher-shell authentication..."
cypher-shell -u neo4j -p mypass "RETURN 1;"

neo4j stop

# Start Neo4j in the foreground
neo4j console

我使用 docker-compose 运行并在日志中得到以下几行:

neo4j  | Testing cypher-shell authentication...
neo4j  | The client is unauthorized due to authentication failure.

我尝试通过设置

NEO4J_AUTH=none
关闭身份验证。我也尝试设置
Neo4J_AUTH=neo4j/neo4j
但我收到相同的身份验证错误。我尝试从
./data
文件夹中删除文件并使用
docker-compose build
标志运行
--no-cache
/var/lib/neo4j/logs/debug.log
好像没有错误。

此外,当我导航到

https://localhost:7474/
时,我会看到一个包含以下内容的页面:

This site can’t be reached
localhost unexpectedly closed the connection.
Try:

Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_CLOSED

如何修复此身份验证错误?

docker authentication docker-compose neo4j
1个回答
0
投票

您可能还有其他问题,但

Dockerfile
中的这一行指定了错误的路径:

RUN chmod +x scripts/entrypoint.sh

用这个代替:

RUN chmod +x /var/lib/neo4j/scripts/entrypoint.sh
© www.soinside.com 2019 - 2024. All rights reserved.