docker-入口点-initdb.d 上的 Arangodb 连接失败

Arangodb connection fail on docker-entrypoint-initdb.d

我正在尝试初始化我的 docker arangodb,但一直出现连接错误:我已尝试将服务器端点更改为 http+tcp://..... 但错误仍然存​​在,会发生什么?

docker-compose.yml:

version: '3.3'
services:
  db:
    container_name: arangodb
    build: .
    environment:
      - ARANGO_DB_NAME="mydba"
      - ARANGO_DB_USER="user"
      - ARANGO_DB_PASSWORD="123"
    ports:
      - '2010:8529'
    expose:
      - '2010'
    volumes:
      - ./arango-dump:/docker-entrypoint-initdb.d

Docker 文件:

FROM arangodb
## Environment variables
ENV ARANGO_ROOT_PASSWORD=123

arango-dump/01-Create.sh:

#!/bin/bash
/usr/bin/arangosh \
--server.endpoint=unix:///tmp/arangodb-tmp.sock \
--server.password ${ARANGO_ROOT_PASSWORD} \
--javascript.execute-string "db._createDatabase(${ARANGO_DB_NAME}, [{username: ${ARANGO_DB_USER}, password: ${ARANGO_DB_PASSWORD}}]);"

错误:

arangodb | /entrypoint.sh: running /docker-entrypoint-initdb.d/01-Create.sh
arangodb | 2020-03-25T03:49:52Z [255] ERROR [979b9] JavaScript exception in file '/usr/share/arangodb3/js/client/modules/@arangodb/arango-database.js' at 1017,40: ArangoError 2001: not connected\n!  var requestResult = this._connection.POST('/_api/database', data);\n!                                       ^\nstacktrace: ArangoError: not connected\n    at Proxy.ArangoDatabase._createDatabase (/usr/share/arangodb3/js/client/modules/@arangodb/arango-database.js:1017:40)\n    at (command-line):1:4\n
arangodb exited with code 1

非常感谢

为您的服务器端点使用端口 8999

--server.endpoint=tcp://127.0.0.1:8999

这适用于 3.6.2。

在您的情况下,不需要 Dockerfile,也不需要 docker-compose.yml 中的 expose