orientechnologies / orientdb-docker

OrientDB running in a docker container
MIT License
63 stars 63 forks source link

Can't set root password for OrientDB using docker-compose #21

Closed iamdeit closed 7 years ago

iamdeit commented 7 years ago

If I pass the ORIENTDB_ROOT_PASSWORD in a docker-compose file it does not work. My SO thread: http://stackoverflow.com/questions/40640901/cant-set-root-password-for-orientdb-using-docker-compose

robfrank commented 7 years ago

I saw you solved the problem.

capital-G commented 7 years ago

I am still not able to login when I use docker-compose. With standalone docker it works.

version: "3"

volumes:
  db:

services:
  db:
    image: orientdb:2.2.26
    hostname: db
    environment:
      - ORIENTDB_ROOT_PASSWORD=test
    ports:
      - "2424:2424"
      - "2434:2434"
      - "2480:2480"
    volumes:
      - db:/orientdb/databases

When I attach to the shell in the running docker-compose-db container I get

/orientdb # printenv
ORIENTDB_ROOT_PASSWORD=test
JAVA_ALPINE_VERSION=8.131.11-r2
ORIENTDB_DOWNLOAD_MD5=51f07639db0cce7574be6fe0c90e3ba7
HOSTNAME=db
SHLVL=1
HOME=/root
ORIENTDB_DOWNLOAD_URL=http://central.maven.org/maven2/com/orientechnologies/orientdb-community/2.2.26/orientdb-community-2.2.26.tar.gz
ORIENTDB_VERSION=2.2.26
JAVA_VERSION=8u131
TERM=xterm
PATH=/orientdb/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
LANG=C.UTF-8
PWD=/orientdb
JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ORIENTDB_DOWNLOAD_SHA1=7b58eed99b5c5c03139eaa16718e2b048ffcd046
/orientdb # 

Edit: Found the solution. You got to use docker-compose down to complelty remove the database - somehow the root password is stored in the database, I think this should not be.

robfrank commented 7 years ago

I created a compose and run it. It works. I'm able to create a db with root/test pointing the browser to localhost:2480

capital-G commented 7 years ago

Yes, but once you change the password in the environment variable you can't connect to the database anymore. For that, first create an OrientDB container with docker-compose and after that change the password/environment variable in the docker-compose file - after that it is not possible to create any database anymore because of login issues.

I'm unsure if this contradicts the philosophy of a stateless container.

robfrank commented 7 years ago

I don't understand. Please explain and detail this: "Yes, but once you change the password in the environment variable you can't connect to the database anymore." It's not clear to what you're doing.

capital-G commented 7 years ago

First I create a docker-compose.yml file which contains

version: "3"

volumes:
  db:

services:
  db:
    image: orientdb:2.2.26
    hostname: db
    environment:
      - ORIENTDB_ROOT_PASSWORD=test
    ports:
      - "2424:2424"
      - "2434:2434"
      - "2480:2480"
    volumes:
      - db:/orientdb/databases

Then docker-compose up and now it works - so lets stop it with ctrl + c.

After that I modify my docker-compose.yml file, so the environment variable ORIENTDB_ROOT_PASSWORD is something different, let's say I modify my docker-compose.yml like this

version: "3"

volumes:
  db:

services:
  db:
    image: orientdb:2.2.26
    hostname: db
    environment:
      - ORIENTDB_ROOT_PASSWORD=root
    ports:
      - "2424:2424"
      - "2434:2434"
      - "2480:2480"
    volumes:
      - db:/orientdb/databases

let's enter docker-compose up. Now I won't be able to login anymore with the set root password root. I'm unsure if this is a real bug, maybe it contradicts the stateless philosophy of a container, at least it gave me a bit of headache because I pointed to an OrientDB which was created with another root user.

When i type docker-compose down and after that docker-compose up I'm now able to login with root as password because the database was deleted.

robfrank commented 7 years ago

It's not related to the container, but on how OrientDB persists its configuration files. The password (hashed) of the root user is stored in the orientdb-server-config.xml file. I suspect that with ctrl-c the container isn't deleted, while with down/up it is recreated. So, the first time the password change hasn't effect, the second time is on a fresh container.