Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not connected when running init shell scripts #69

Open
mhaagens opened this issue May 30, 2019 · 1 comment
Open

Not connected when running init shell scripts #69

mhaagens opened this issue May 30, 2019 · 1 comment
Labels

Comments

@mhaagens
Copy link

I'm trying to create a new database on init, but I'm only getting errors saying it's not connected.

Error:

ERROR JavaScript exception in file '/usr/share/arangodb3/js/client/modules/@arangodb/arango-database.js' at 388,40: ArangoError 2001: not connected\n!  var requestResult = this._connection.POST(this._collectionurl() + urlAddon, body);\n!                                       ^\nstacktrace: ArangoError: not connected\n    at Proxy.ArangoDatabase._create (/usr/share/arangodb3/js/client/modules/@arangodb/arango-database.js:388:40)\n    at (command-line):1:4\n

docker-compose.yml

version: "3"
services:
  arangodb:
    build:
      context: ./docker/arangodb
      dockerfile: Dockerfile
    environment:
      - ARANGO_STORAGE_ENGINE=rocksdb
      - ARANGO_ROOT_PASSWORD=password
      - ARANGO_DB="test"
      - ARANGO_DB_USER="test"
      - ARANGO_DB_PASSWORD="test"
    volumes:
      - ./docker/arangodb/data:/var/lib/arangodb3
    ports:
      - 8529:8529

./docker/arangodb/Dockerfile

FROM arangodb/arangodb:latest
COPY ./config/init/ /docker-entrypoint-initdb.d/
RUN chmod -R 755 /docker-entrypoint-initdb.d/

/docker-entrypoint-initdb.d/001-create-database.sh

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

Hi,
by default the arangodb docker container doesn't bind unix domain sockets. You can however make it do so by specifying it should do (this example chooses to disable authentification for simplicity):

docker run -it -e ARANGO_NO_AUTH=1 --server.endpoint unix:///tmp/arangodb-tmp.sock

then your arangosh should be able to connect to that unix domain socket.

A nice addon is, that you could share that socket with your host if you mount the filesystem the socket is created on into the container using -v:

docker run -v /var/run/arangodb/:/tmp/ -it -e ARANGO_NO_AUTH=1 --server.endpoint unix:///tmp/arangodb-tmp.sock

you could then connect it from the host like that:

/usr/bin/arangosh --server.endpoint unix:///var/run/arangodb/arangodb-tmp.sock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants