Docker volume path to keep the PG database on restart

Hi guys,

I would like to know what paths I should mount to keep data of my testing docker instance.

When I start the container I can see that multiple temporary volumes are created.

I tried to mount a volume in var/lib/pgsql/data but the rails server doesn’t want to start anymore after a restart.

What i’ve done:

docker volume create miq_db

docker run -d  \
-p 8443:443 \
--dns 16.110.135.52 \
-v miq_db:/var/lib/pgsql/data \
manageiq/manageiq:jansa-2

docker volume ls    
DRIVER              VOLUME NAME
local               59a0a5eadda6be6af585d00b1de80014e74d42de33c657cfedd2cbcfe05307db
local               5689052f9922f38d352193620a73d1d68433d4eda88393db2faca5dffababd0c
local               a602d622e82a15e5a0b1ed3fc332433e07b926cec479666f209ffccc77a70e9c
local               miq_db

The server start correctly. If I kill the container and then restart the DB fail to start.

== Checking MIQ database status ==
** DB already initialized
** Starting postgresql
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2020-11-02 16:08:29.222 UTC [26] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2020-11-02 16:08:29.222 UTC [26] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2020-11-02 16:08:29.222 UTC [26] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-11-02 16:08:29.224 UTC [26] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-11-02 16:08:29.226 UTC [26] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-02 16:08:29.235 UTC [26] LOG:  redirecting log output to logging collector process
2020-11-02 16:08:29.235 UTC [26] HINT:  Future log output will appear in directory "log".
 done
server started
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/opt/manageiq/manageiq-gemset/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/opt/manageiq/manageiq-gemset/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/opt/manageiq/manageiq-gemset/bin/bundle:23:in `load'
/opt/manageiq/manageiq-gemset/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
  /var/www/miq/vmdb/certs/v2_key doesn't exist!
  On an appliance, it should be generated on boot by evmserverd.

  If you're a developer, you can copy the /var/www/miq/vmdb/certs/v2_key.dev to /var/www/miq/vmdb/certs/v2_key.

  Caution, using the developer key will allow anyone with the public developer key to decrypt the two-way
  passwords in your database.
{"@timestamp":"2020-11-02T16:08:33.429438 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0"}
{"@timestamp":"2020-11-02T16:08:33.547129 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(MiqServer.load_or_generate_guid) Generated MiqServer GUID 1e172835-f452-4e01-a841-8d83be567a08"}
{"@timestamp":"2020-11-02T16:08:33.600705 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for azure.log has been changed to [WARN]"}
{"@timestamp":"2020-11-02T16:08:33.600952 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for vim.log has been changed to [WARN]"}
{"@timestamp":"2020-11-02T16:08:33.672644 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(SessionStore) Using session_store: ActionDispatch::Session::MemCacheStore"}
{"@timestamp":"2020-11-02T16:08:33.761330 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"Dalli::Server#connect 127.0.0.1:11211"}
{"@timestamp":"2020-11-02T16:08:33.882088 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"Initializing Environment for API"}
{"@timestamp":"2020-11-02T16:08:33.882261 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":""}
{"@timestamp":"2020-11-02T16:08:33.882345 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"Static Configuration"}
{"@timestamp":"2020-11-02T16:08:33.882440 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  module                  : api"}
{"@timestamp":"2020-11-02T16:08:33.882503 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  name                    : API"}
{"@timestamp":"2020-11-02T16:08:33.882566 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  description             : REST API"}
{"@timestamp":"2020-11-02T16:08:33.882626 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":""}
{"@timestamp":"2020-11-02T16:08:33.882686 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"Dynamic Configuration"}
{"@timestamp":"2020-11-02T16:08:33.884494 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  token_ttl               : 10.minutes"}
{"@timestamp":"2020-11-02T16:08:33.884598 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  authentication_timeout  : 30.seconds"}
{"@timestamp":"2020-11-02T16:08:33.884667 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"  max_results_per_page    : 1000"}
{"@timestamp":"2020-11-02T16:08:33.884764 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(Vmdb::Initializer.init) - Program Name: /var/www/miq/vmdb/lib/workers/bin/evm_server.rb, PID: 6, ENV['EVMSERVER']: "}
{"@timestamp":"2020-11-02T16:08:33.884991 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0"}
{"@timestamp":"2020-11-02T16:08:35.823150 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0"}
{"@timestamp":"2020-11-02T16:08:35.836051 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0"}
{"@timestamp":"2020-11-02T16:08:35.836615 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(EvmServer#validate_database) Database Adapter: [PostgreSQL], version: [PostgreSQL 10.14 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit]"}
{"@timestamp":"2020-11-02T16:08:36.057393 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(EvmDatabase.seed_classes) Seeding..."}
{"@timestamp":"2020-11-02T16:08:36.058133 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"MIQ(MiqDatabase.with_lock) Acquiring lock on MiqDatabase (table: miq_databases..."}
{"@timestamp":"2020-11-02T16:08:36.058564 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"MIQ(MiqDatabase.with_lock) Acquired lock on MiqDatabase (table: miq_databases..."}
{"@timestamp":"2020-11-02T16:08:36.058743 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"info","message":"MIQ(EvmDatabase.seed_classes) Seeding MiqDatabase..."}
{"@timestamp":"2020-11-02T16:08:36.085579 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"debug","message":"MIQ(MiqDatabase.with_lock) Releasing lock on MiqDatabase (table: miq_databases..."}
{"@timestamp":"2020-11-02T16:08:36.086177 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"err","message":"[ManageIQ::Password::PasswordError]: can not decrypt v2_key encrypted string  Method:[block (2 levels) in \u003cclass:LogProxy\u003e]"}
{"@timestamp":"2020-11-02T16:08:36.086318 ","hostname":"fdc989ad92e8","pid":6,"tid":"2ac4452c994c","level":"err","message":"/opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:43:in `rescue in decrypt'\n/opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:40:in `decrypt'\n/opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:72:in `decrypt'\n/var/www/miq/vmdb/app/models/mixins/password_mixin.rb:24:in `block in encrypt_column'\n/var/www/miq/vmdb/app/models/miq_database.rb:54:in `seed'\n/var/www/miq/vmdb/lib/evm_database.rb:120:in `block (4 levels) in seed_classes'\n/opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'\n/usr/share/ruby/benchmark.rb:308:in `realtime'\n/opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'\n/var/www/miq/vmdb/lib/evm_database.rb:120:in `block (3 levels) in seed_classes'\n/var/www/miq/vmdb/lib/evm_database.rb:118:in `each'\n/var/www/miq/vmdb/lib/evm_database.rb:118:in `block (2 levels) in seed_classes'\n/var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block (2 levels) in with_lock'\n/usr/share/ruby/timeout.rb:93:in `block in timeout'\n/usr/share/ruby/timeout.rb:33:in `block in catch'\n/usr/share/ruby/timeout.rb:33:in `catch'\n/usr/share/ruby/timeout.rb:33:in `catch'\n/usr/share/ruby/timeout.rb:108:in `timeout'\n/var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block in with_lock'\n/opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'\n/opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'\n/usr/share/ruby/monitor.rb:230:in `mon_synchronize'\n/opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'\n/opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'\n/opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/transactions.rb:212:in `transaction'\n/var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:15:in `with_lock'\n/var/www/miq/vmdb/lib/evm_database.rb:117:in `block in seed_classes'\n/opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'\n/usr/share/ruby/benchmark.rb:308:in `realtime'\n/opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'\n/var/www/miq/vmdb/lib/evm_database.rb:115:in `seed_classes'\n/var/www/miq/vmdb/lib/evm_database.rb:70:in `seed'\n/var/www/miq/vmdb/lib/evm_database.rb:79:in `seed_primordial'\n/var/www/miq/vmdb/lib/workers/evm_server.rb:25:in `start'\n/var/www/miq/vmdb/lib/workers/evm_server.rb:81:in `start'\n/var/www/miq/vmdb/lib/workers/bin/evm_server.rb:4:in `\u003cmain\u003e'"}
/opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:43:in `rescue in decrypt': can not decrypt v2_key encrypted string (ManageIQ::Password::PasswordError)
	from /opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:40:in `decrypt'
	from /opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:72:in `decrypt'
	from /var/www/miq/vmdb/app/models/mixins/password_mixin.rb:24:in `block in encrypt_column'
	from /var/www/miq/vmdb/app/models/miq_database.rb:54:in `seed'
	from /var/www/miq/vmdb/lib/evm_database.rb:120:in `block (4 levels) in seed_classes'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
	from /usr/share/ruby/benchmark.rb:308:in `realtime'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'
	from /var/www/miq/vmdb/lib/evm_database.rb:120:in `block (3 levels) in seed_classes'
	from /var/www/miq/vmdb/lib/evm_database.rb:118:in `each'
	from /var/www/miq/vmdb/lib/evm_database.rb:118:in `block (2 levels) in seed_classes'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block (2 levels) in with_lock'
	from /usr/share/ruby/timeout.rb:93:in `block in timeout'
	from /usr/share/ruby/timeout.rb:33:in `block in catch'
	from /usr/share/ruby/timeout.rb:33:in `catch'
	from /usr/share/ruby/timeout.rb:33:in `catch'
	from /usr/share/ruby/timeout.rb:108:in `timeout'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block in with_lock'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
	from /usr/share/ruby/monitor.rb:230:in `mon_synchronize'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/transactions.rb:212:in `transaction'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:15:in `with_lock'
	from /var/www/miq/vmdb/lib/evm_database.rb:117:in `block in seed_classes'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
	from /usr/share/ruby/benchmark.rb:308:in `realtime'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'
	from /var/www/miq/vmdb/lib/evm_database.rb:115:in `seed_classes'
	from /var/www/miq/vmdb/lib/evm_database.rb:70:in `seed'
	from /var/www/miq/vmdb/lib/evm_database.rb:79:in `seed_primordial'
	from /var/www/miq/vmdb/lib/workers/evm_server.rb:25:in `start'
	from /var/www/miq/vmdb/lib/workers/evm_server.rb:81:in `start'
	from /var/www/miq/vmdb/lib/workers/bin/evm_server.rb:4:in `<main>'
/opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:41:in `decrypt': undefined method `decrypt64' for nil:NilClass (NoMethodError)
	from /opt/manageiq/manageiq-gemset/gems/manageiq-password-0.3.0/lib/manageiq/password.rb:72:in `decrypt'
	from /var/www/miq/vmdb/app/models/mixins/password_mixin.rb:24:in `block in encrypt_column'
	from /var/www/miq/vmdb/app/models/miq_database.rb:54:in `seed'
	from /var/www/miq/vmdb/lib/evm_database.rb:120:in `block (4 levels) in seed_classes'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
	from /usr/share/ruby/benchmark.rb:308:in `realtime'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'
	from /var/www/miq/vmdb/lib/evm_database.rb:120:in `block (3 levels) in seed_classes'
	from /var/www/miq/vmdb/lib/evm_database.rb:118:in `each'
	from /var/www/miq/vmdb/lib/evm_database.rb:118:in `block (2 levels) in seed_classes'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block (2 levels) in with_lock'
	from /usr/share/ruby/timeout.rb:93:in `block in timeout'
	from /usr/share/ruby/timeout.rb:33:in `block in catch'
	from /usr/share/ruby/timeout.rb:33:in `catch'
	from /usr/share/ruby/timeout.rb:33:in `catch'
	from /usr/share/ruby/timeout.rb:108:in `timeout'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:21:in `block in with_lock'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
	from /usr/share/ruby/monitor.rb:230:in `mon_synchronize'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
	from /opt/manageiq/manageiq-gemset/gems/activerecord-5.2.4.4/lib/active_record/transactions.rb:212:in `transaction'
	from /var/www/miq/vmdb/lib/extensions/ar_table_lock.rb:15:in `with_lock'
	from /var/www/miq/vmdb/lib/evm_database.rb:117:in `block in seed_classes'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
	from /usr/share/ruby/benchmark.rb:308:in `realtime'
	from /opt/manageiq/manageiq-gemset/gems/activesupport-5.2.4.4/lib/active_support/core_ext/benchmark.rb:14:in `ms'
	from /var/www/miq/vmdb/lib/evm_database.rb:115:in `seed_classes'
	from /var/www/miq/vmdb/lib/evm_database.rb:70:in `seed'
	from /var/www/miq/vmdb/lib/evm_database.rb:79:in `seed_primordial'
	from /var/www/miq/vmdb/lib/workers/evm_server.rb:25:in `start'
	from /var/www/miq/vmdb/lib/workers/evm_server.rb:81:in `start'
	from /var/www/miq/vmdb/lib/workers/bin/evm_server.rb:4:in `<main>'

Many thanks by advance for your help !

The certificates need to be kept too.

docker run -d  \
-p 8443:443 \
-v miq_db:/var/lib/pgsql/data \
-v miq_certs:/var/www/miq/vmdb/certs \
manageiq/manageiq:jansa-2