设置了neo4j和密码的Docker容器

Tro*_*els 3 neo4j dockerfile

我正在尝试创建一个运行Neo4j服务器的docker镜像,并且不要求用户在初始访问时手动设置密码.

我有这个作为Dockerfile

FROM neo4j:3.2
ADD setPassword.sh .
RUN ./setPassword.sh
Run Code Online (Sandbox Code Playgroud)

运行此脚本

#!/bin/sh

set -e

# Start server
./bin/neo4j start

# Wait for it to start
while [ -z "$(grep 'Remote interface available' /var/lib/neo4j/logs/neo4j.log)" ]
do
    echo Waiting for neo4j to start
    sleep 1
done

# Set the password via REST
wget --header="Content-Type: application/json" \
     --post-data='{"password": "newPassword"}'    \
     http://neo4j:neo4j@localhost:7474/user/neo4j/password

# Shut down the server
./bin/neo4j stop

tail -f /var/lib/neo4j/logs/neo4j.log &
sleep 10
# EOF
Run Code Online (Sandbox Code Playgroud)

该脚本启动Neo4j服务器,等待它启动,然后使用REST API设置密码.之后,它会关闭服务器并等待一段时间以确保它已关闭,以便内存中的任何内容都刷新到磁盘.

该脚本似乎运行没有错误,我能够创建一个新的图像.但是,当我运行图像并使用浏览器连接时,密码仍然是neo4j.

查看wget没有参数的输出:

BusyBox v1.26.2 (2017-06-11 06:38:32 GMT) multi-call binary.

Usage: wget [-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]
  [--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
  [-U|--user-agent AGENT] [-T SEC] URL...

Retrieve files via HTTP or FTP

  --spider  Spider mode - only check file existence  
  -c        Continue retrieval of aborted transfer
  -q        Quiet
  -P DIR        Save to DIR (default .)
  -T SEC        Network read timeout is SEC seconds
  -O FILE       Save to FILE ('-' for stdout)
  -U STR        Use STR for User-Agent header
  -Y on/off Use proxy
Run Code Online (Sandbox Code Playgroud)

它看起来像wget基本图像中不支持大多数标准wget选项,包括发布帖子请求.

我也没弄明白如何curl在图像中安装标准:

bash-4.3# apk add curl
WARNING: Ignoring APKINDEX.84815163.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.24d64ab1.tar.gz: No such filapk e or directory
ERROR: unsatisfiable constraints:
  curl (missing):
    required by: world[curl]
Run Code Online (Sandbox Code Playgroud)

apk fetchask search提供有关丢失tar.gz文件的类似错误.

我没有任何附件使用REST API:我想要的东西,我可以自动构建和没有当我的程序访问数据库重置密码.

我确实在过去遇到过一个问题,Dockerfile中的更改因丢失而丢失,因为基本映像VOLUME在保存该更改的目录上执行了命令,但看起来只是/data导出它并且它似乎不包含任何授权信息.

std*_*b-- 14

您可以覆盖docker文件中的登录密码:

FROM neo4j:3.2
ENV NEO4J_AUTH=neo4j/newPassword
Run Code Online (Sandbox Code Playgroud)