arangodb / arangodb-docker

Docker container for ArangoDB
Apache License 2.0
106 stars 32 forks source link

Connection refused when running JavaScript files on server init #29

Closed stephanwilliams closed 7 years ago

stephanwilliams commented 7 years ago

I'm using Docker 1.13.1 on Mac OS X 10.11.6.

I have a Dockerfile that derives from the arangodb 3.1.11 image and COPYs a JavaScript file into /docker-entrypoint-initdb.d so it'll be run when the database is initialized. However, I get the following error when the script runs:

arango_1  | 2017-02-22T07:20:58Z [109] ERROR JavaScript exception in file '/usr/share/arangodb3/js/client/modules/@arangodb/arangosh.js' at 97,7: ArangoError 2001: Could not connect to 'http+tcp://127.0.0.1:8529' 'connect() failed with #111 - Connection refused'
arango_1  | 2017-02-22T07:20:58Z [109] ERROR !      throw error;
arango_1  | 2017-02-22T07:20:58Z [109] ERROR !      ^

The error is thrown from the first function call that tries to talk to the database, in my case db._createDatabase(...).

I did find a workaround for this, which was to put the following shell script into /docker-entrypoint-initdb.d instead of the js file:

#!/usr/bin/bash

/usr/bin/arangosh --server.authentication false --server.endpoint unix:///tmp/arangodb-tmp.sock \
    --javascript.execute /path/to/my/init/script.js

The initial --server.* arguments are taken from the arangosh invocations in docker-entrypoint3.sh.

So my question is, shouldn't the arangosh call on line 73 also have those same two arguments?

dothebart commented 7 years ago

Yes, you're perferctly right! I've fixed it along the lines you've sugested, and added tests so we will find out if it breaks in future.

dothebart commented 7 years ago

It has been merged, so a new 3.1.20 issue on the docker library will contain this fix. Thanks for reporting.