boschkundendienst / guacamole-docker-compose

Guacamole with docker-compose using PostgreSQL, nginx with SSL (self-signed)
GNU General Public License v3.0
955 stars 398 forks source link

External Database Server and acessing internal database #64

Closed SnowyJaguar1034 closed 1 year ago

SnowyJaguar1034 commented 1 year ago

Hi, Since my last 'issue' I've been fairly busy so I've not had time to look into deploying your stack/compose but I've now got a bit more time. I've recently setup a postgres database container to act as a central database for all of my containers instead of each of them having their own. I just have a few questions about deploying you stack/compose.

Sorry for creating issues for these questions, If you had the 'Disscussions' feature enabled then I would have asked there.

boschkundendienst commented 1 year ago

Hi,

just read the docker-compose.yml file to get an understanding how my stack works and this is the only way I support running it.

If you do something different, don't use my issue tracker for your bugs. Fork my source and then support your changes yourself.

To anser your questions:

Does the guacamole service create it's own database (POSTGRES_DATABASE: guacamole) or does the postgres service do that?

As you can see in this part of docker-compose.yml the database is created by the postgres container itself. Especially as documented here especially the part about Initialization scripts. prepare.sh extracts the initdb.sql from the guacamole docker image and puts it into ./init/initdb.sql The process is by the way documented in detail in the docker-compose.yml file.

If it doesn't I'd have to prepare that ahead of time myself right? Could I put something in the compose to make it for me? You should learn how docker, docker-compose and containers in general work before using them. This is not a trial and error game, this is real IT!

Sorry to be so rude but this is not the Guacamole User Helpdesk. Everything about Guacamole is documented here.

Regards

Bosch

SnowyJaguar1034 commented 1 year ago

Hi, Thank you for getting back to me.

I, unfortunately, didn't get my 'central' database idea to work due to permission issues I could not resolve.

So I instead just spun up the postgres instance in the stack. I have then been trying to access the postgres db from my pgadmin interface; however, I can't connect. I've already adjusted the stack to expose the postgres server on binding 5432:5432; however, I can't connect. I exec'd into the container to try to run some psql commands but I can't even connect to the db from within the container. I've tried suto get into the postgres user account but a 'role does not exist' error

root@ve:~# docker exec -it c01ca1b151ba bash
c01ca1b151ba:/# su postgres
/ $ psql
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "postgres" does not exist
/ $

I then tried the same command with guacamole_user but I get 'unknown user'. I then tried the following with no success

c01ca1b151ba:/var/lib/postgresql/data/guacamole# psql --host=localhost --port=5432 --username=postgres --password --dbname=guacamole
Password:
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  role "postgres" does not exist
c01ca1b151ba:/var/lib/postgresql/data/guacamole# psql --host=localhost --port=5432 --username=guacamole --password --dbname=guacamole
Password:
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  role "guacamole" does not exist
c01ca1b151ba:/var/lib/postgresql/data/guacamole#

I've had a good Google and looked at some of the common files people say to edit like pg_hba.conf and postgresql.conf and those files appear to suggest I should be able to access the db. I also checked the postgres service is actually running and it is. Have you manged to connect to the db inn the container before? Is this question better suited to the guacamole team?

boschkundendienst commented 1 year ago

Hi, as far as I understand you want to use your own PostgreSQL instance. Well then you have to learn it. I just can show you in this video, that it is definitely possible to connect to the PostgreSQL database that runs within a container. Of course I took my setup as a reference. Maybe this helps? Anyways PostgreSQL is very tricky when it comes to versions. You can only handle a database with a specific version with the management tools that have the same version.

Take a look here and see that it works. (Asciinema video)

I tested this a few minutes ago.

SnowyJaguar1034 commented 1 year ago

Hi, just following up with this.

I originally wanted to use my own postgres instance and I did go down that path however I'd obviously got something wrong in the configuration somewhere because I was consistently getting a user permission (or possibly table permissions) error.

So once I'd spent a few hours trying to get this to work I had the idea to redeploy (all of) the containers from your compose (including your postgres) following your guidance and I got that to work (which was expected).

The stage I'm at now, and that my previous comment was referring to, is to make the postgres container from your compose accessible to a) primarily my pgadmin container to make the database easier to manage if that ever needs to happen and b) so that I can add my own databases into the database server.

Thanks for sending over that video, I'll take a look at it this weekend.

All of the issues I was having with accessing the psql cli ( the ones I showed code blocks for) were all for the postgres container included in your compose, I wasn't having those issues with the container I deployed separately. This may have been a configuration issue on my end, a configuration issue on your end or configuration issue from Apache Guacamole's images but I don't know enough to say definitively.

If your able to access the psql cli included in the postgres container from your compose then that would indicate it's an issue with my configuration however I did test deploy the compose 2 or 3 times and consistently had this issue so either I'm consistently making the same config issue or something else is going on.

Apologies for any confusion my previous comment caused about what I was saying and asking about.