Search code examples
docker-composepermission-deniedvolumes

Permission denied error with docker-compose volume


I'm trying to connect volumes in my docker-compose.yml file but I get the permission denied error. I'm on Ubuntu 22.

The file looks like this:

version: '3'
services:
  jupyter:
    user: root
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./:/home/jovyan/
    ports:
      - '8888:8888'
  db:
    image: postgres
    restart: always
    ports:
      - '5432:8888'
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

But when I try to run the command docker-compose up I get the error PermissionError: [Errno 13] Permission denied: '/home/jovyan/.local/share/jupyter/runtime/jpserver-16-open.html'

I tried to run the following commands from docker site:

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Then I rebooted, but the error persists.

I also tried this answer and tried to run the command with sudo.


Solution

  • Solved problem by changing the line

    - ./:/home/jovyan/
    

    to

    - ./:/home/jovyan/work