Secure-Compliance-Solutions-LLC / GVM-Docker

Greenbone Vulnerability Management Docker Image with OpenVAS
https://securecompliance.gitbook.io/projects/
MIT License
247 stars 91 forks source link

11.0.1-r1: postgres is not able to start #41

Closed forkedjensh closed 4 years ago

forkedjensh commented 4 years ago

Describe the bug Containers based on this image won't start because pg_ctl is missing its config files postgresql.conf, pg_ident.conf and pg_hba.conf.

To Reproduce Steps to reproduce the behavior:

  1. Run docker run --rm securecompliance/gvm:11.0.1-r1 (for simplicity I didn't set any environment variables and assigned no volume)
  2. Check output:
    ➜ docker run --rm securecompliance/gvm:11.0.1-r1
    8:C 14 Jun 2020 10:30:18.227 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    8:C 14 Jun 2020 10:30:18.227 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8, just started
    8:C 14 Jun 2020 10:30:18.227 # Configuration loaded
    Wait for redis socket to be created...
    Testing redis status...
    Redis ready.
    Creating Data folder...
    Creating Database folder...
    Starting PostgreSQL...
    waiting for server to start....postgres: could not access the server configuration file "/data/database/postgresql.conf": No such file or directory
    stopped waiting
    pg_ctl: could not start server
    Examine the log output.

Expected behavior A running container is created.

Screenshots ./.

Additional context It seems that pg_ctl is missing postgresql.conf, pg_ident.conf and pg_hba.conf. I am no expert on postgresql but using these files from /etc/postgresql/12/main/ creates a running container.

[EDIT] Specify version/tag

forkedjensh commented 4 years ago

I'm not sure if the changes in MR #42 are the best solution but it allows the container to be created.

pixelsquared commented 4 years ago

I have pushed a change to master to that should fix this issue. Could you test and confirm?

forkedjensh commented 4 years ago

There's quite a bit to go. The creation of /data/dababase and running chown has to happen before initdb, so moving it to before initdb in the if clause would do the trick.

Current output:

➜ docker run --rm securecompliance/gvm
8:C 14 Jun 2020 12:48:10.092 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8:C 14 Jun 2020 12:48:10.092 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8, just started
8:C 14 Jun 2020 12:48:10.092 # Configuration loaded
Wait for redis socket to be created...
Testing redis status...
Redis ready.
Creating Data folder...
Creating Database folder...
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /data/database ... initdb: error: could not create directory "/data/database": Permission denied
pixelsquared commented 4 years ago

Sorry about that I didn't have time to test the change. I should have waited to push it. I pushed a new change and I am testing it now.

forkedjensh commented 4 years ago

Starting postgresql works now. Thanks!

sjwk commented 4 years ago

Is this actually fixed? (Or maybe my issue is different and I should start a new ticket?) I updated my container to the latest image, with an existing database and it's not starting due to missing config files as above.

gvm | Starting PostgreSQL... gvm | pg_ctl: another server might be running; trying to start server anyway gvm | waiting for server to start....postgres: could not access the server configuration file "/data/database/postgresql.conf": No such file or directory gvm | stopped waiting gvm | pg_ctl: could not start server

REPOSITORY TAG IMAGE ID CREATED SIZE securecompliance/gvm latest d758bbbd0477 9 hours ago 2.41GB

Does it only initialize the postgresql directory if there isn't an existing database? Surely I don't need to blow away my existing configuration on upgrade?

pixelsquared commented 4 years ago

@sjwk could you open a new ticket?