简体   繁体   中英

rails application on docker-compose: db:migration shows "Permission denied"

I'm running a rails app on docker-compose image. After I created a user devise, when I run docker-compose run web rails db:migrate it shows the following error: PG::ConnectionBad: FATAL: could not open relation mapping file "global/pg_filenode.map": Permission denied

I have tried all the solutions rails and psql related, so I'm guessing my problem is with the docker-compose program somehow, I also tried with sudo but the result is the same

Code: The command I run is docker-compose run web rails db:migrate after docker-compose run web rails g devise usuario

and this is the output:

rails aborted!
PG::ConnectionBad: FATAL:  could not open relation mapping file "global/pg_filenode.map": Permission denied
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `initialize'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `new'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `connect'

Rest of the log in this link: https://hastebin.com/axiboxohem.bash

It turned out that somehow there were multiple containers of the same image on Docker. I could see the extra containers mounted with docker ps -a -q , and removed them with docker rm $(docker ps -a -q) . That did it for me, I guess one of the containers was holding to the file.

your problem seems to be just in the connection with Postgresql, check out your postgres service is up or if you have the right permission in the folder. Look this, maybe help: Postgres is failing with 'could not open relation mapping file "global/pg_filenode.map" '

运行docker stop $(docker ps -q)停止所有正在运行的容器docker stop $(docker ps -q)试。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM