设置了neo4j和密码的Docker容器

时间:2017-10-11 22:09:12

标签: neo4j dockerfile

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

我有这个作为Dockerfile

http://sldn.softlayer.com/reference/services/SoftLayer_Account_Partner_Business/12345/getObject

运行此脚本

FROM neo4j:3.2
ADD setPassword.sh .
RUN ./setPassword.sh

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

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

查看#!/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 没有参数的输出:

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 似乎不支持大多数标准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] apk fetch会针对丢失的ask search文件提供类似的错误。

我对使用REST api没有任何依据:我想要一些我可以自动构建的东西,而不需要在我的程序访问数据库时重置密码。

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

1 个答案:

答案 0 :(得分:10)

您可以覆盖泊坞窗文件中的登录密码:

FROM neo4j:3.2
ENV NEO4J_AUTH=neo4j/newPassword