apache / pulsar-manager

Apache Pulsar Manager
https://pulsar.apache.org/
Apache License 2.0
515 stars 244 forks source link

Only start Postgresql in the Docker container if required #196

Open rocketraman opened 4 years ago

rocketraman commented 4 years ago

The docker image currently fires up its own PostgresQL database. I'd prefer to use an existing database I already have. It's trivial to create my own image, but it would be nice if this was an option.

tuteng commented 4 years ago

Sorry, I just noticed this issue.

You can use the following command to connect to other databases. However, note that your docker image should be connected to the database network. Use your database address, account and password to replace the database address, account and password in the command line.

docker run -it -p 9527:9527 -e REDIRECT_HOST=http://192.168.0.104 -e REDIRECT_PORT=9527 -e DRIVER_CLASS_NAME=org.postgresql.Driver -e URL='jdbc:postgresql://127.0.0.1:5432/pulsar_manager' -e USERNAME=pulsar -e PASSWORD=pulsar -v $PWD:/data pulsar-manager:latest /bin/sh

@rocketraman

rocketraman commented 4 years ago

That's what I thought, but on inspecting the docker file, it runs entrypoint.sh, which runs startup.sh, which creates a PG database and starts it, regardless of the presence of the environment variable URL.

I was able to make it work by creating my own Dockerfile and commenting out this entire section of entrypoint.sh:

https://github.com/apache/pulsar-manager/blob/master/docker/entrypoint.sh#L21-L31

rocketraman commented 4 years ago

I guess its more of an efficiency thing than a correctness thing... there is no point in running a local postgres if its not needed.

tuteng commented 4 years ago

You can specify the parameters DRIVER_CLASS_NAME, URL, USERNAME, PASSWORD through the above command to save the data to your custom database. Although a database is also initialized in the container, it is not used. I think I can add an option later. If the user specifies a custom database, it will not start the database in the container. This does not affect its correctness, but it does cause some confusion.

leobenkel commented 4 years ago

the log gets really confusing because i didn't create the data folder and now i am not sure if it cannot connect to the local one that failed or if it failed to connect to the one i pointed it to because of network issue.

pgandhap commented 2 years ago

I am also facing the issue while setting up customised postgresql database . Please help me if someone already had a solution for the same . Please find below steps i followed . 1 . I used below command to set custom postgresql database . docker run -it -p 9527:9527 -p 7750:7750 -e REDIRECT_HOST=http://localhost -e REDIRECT_PORT=9527 -e DRIVER_CLASS_NAME=org.postgresql.Driver -e URL='jdbc:postgresql://127.0.0.1:5432/pulsar_manager' -e USERNAME=postgres -e PASSWORD=postgres -e LOG_LEVEL=DEBUG -e SPRING_CONFIGURATION_FILE=/pulsar-manager/pulsar-manager/application.properties apachepulsar/pulsar-manager:v0.2.0 /bin/sh 2 . After that i set username and password for pulsar-manager using below command . curl -H "X-XSRF-TOKEN:a9e79b0y-5f32-49b9-94a4-26cd4e93da92" -H "Cookie:XSRF-TOKEN=a9e79b0y-5f32-49b9-94a4-26cd4e93da92" -H "Content-Type:application/json" -X PUT http://localhost:7750/pulsar-manager/users/superuser -d "{"name": "admin", "password": "apachepulsar", "description": "test", "email": "pgandha@in.ibm.com"}" 3 . Login to pulsar-manager ui by using above credentials ( admin/apachepulsar ) , which fails . It says incorrect username and password . Any help is highly appreciated . Thanks !!