Docker Community Forums

Share and learn in the Docker community.

PermissionError: [Errno 13] Permission denied: '/home/fred/docker/tmp/db'

I have just installed Docker and I am trying to setup an application server based on Ruby on Rails. These are my first steps with Docker!

Following Compose’s tutorial for Rails, I configured and run containers creation:

docker-compose run web rails new . --force --no-deps --database=postgresql

It runs, fails and then returns:

PermissionError: [Errno 13] Permission denied: ‘/home/fred/docker/tmp/db’

Apparently, the run tries to perform an action on the docker/tmp/db folder, which is owned by systemd-coredump:root while tmp is owned by root:root

Did I make something wrong when installing with sudo ?
How can I solve this?
Thanks!

The first step would be sharing the complete docker-compose.yml - please only redact url, tokens or password and keep everything else untouched.

I am following this tutorial: https://docs.docker.com/compose/rails/
The docker-compose file is the one listed as example:

version: ‘3’
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
web:
build: .
command: bash -c “rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b ‘0.0.0.0’”
volumes:
- .:/myapp
ports:
- “3000:3000”
depends_on:
- db

Then if I change the owner of created folders:

sudo chown -R $USER:$USER .

and then re-run the build, it ends correctly.
As explained in the tutorial, this is probably because Docker runs as root…

1 Like