设置neo4j和密码的码头集装箱
问题描述:
我想创建一个运行Neo4j服务器的码头图像,并且不需要用户在初始访问时手动设置密码。设置neo4j和密码的码头集装箱
我曾以此为Dockerfile
FROM neo4j:3.2
ADD setPassword.sh .
RUN ./setPassword.sh
它运行此脚本
#!/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:[email protected]:7474/user/neo4j/password
# Shut down the server
./bin/neo4j stop
tail -f /var/lib/neo4j/logs/neo4j.log &
sleep 10
# EOF
脚本启动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
它看起来像基本图像中的wget
不支持大多数标准wget
选项,包括做出POST请求。
我也没弄清楚如何在图像中安装标准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
提供有关失踪tar.gz
文件类似的错误。
我没有使用REST api的附件:我想要一些我可以自动构建的东西,而不必在我的程序访问数据库时重置密码。
我确实在过去有一个问题,即在Dockerfile所做的更改在那里失去了,因为基本图像做了保存的更改目录中的VOLUME
命令,但它看起来像只/data
出口并不会出现持有任何授权信息。
答
您可以在泊坞窗文件来覆盖登录密码:
FROM neo4j:3.2
ENV NEO4J_AUTH=neo4j/newPassword