Here is my dockerfile and here is my docker-compose file. When I ran docker-compose run web rake db:migrate I got this err
rake aborted!
failed to execute:
pg_dump -s -x -O -f /usr/src/app/db/structure.sql --schema=public --schema=partitioning docker_rails_dev
Please check the output above for any errors and make sure that `pg_dump` is installed in your PATH and has proper permissions.
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/postgresql_database_tasks.rb:90:in `run_cmd'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/postgresql_database_tasks.rb:55:in `structure_dump'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:183:in `structure_dump'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:53:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:structure:dump
(See full trace by running task with --trace)
so I entered into postgres container and ran pg_dump and got this err
pg_dump: [archiver (db)] connection to database "root" failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
but running pg_dump --version gives me the version number of postgres.
any idea why this is happening?
pg_dump --versiongives you version of pg_dump :-) If you connect into container you run as root and plainpg_dumpcommand in that case tries to connect as user "root" to the database "root". You need to add parameters like -U and -d - check in documentation. Plus check pg_hba.conf file - it contains "allowances" for users to connect.