Error 'Permission Denied' using Docker to install custom dependencies

Hello,

I’m using Rasa and Rasa-X for a bit more than a month. I want to use Custom Actions, and I need to include some dependencies which are not included in rasa_sdk default image. I followed the guide (https://hub.docker.com/r/rasa/rasa-sdk) and read about other users that had the same issue, but I could not solve it and have a “Permission Denied” error.

Building app
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 72, in main
    command()
  File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 128, in perform_command
    handler(command, command_options)
  File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 303, in build
    progress=options.get('--progress'),
  File "/usr/local/lib/python3.6/dist-packages/compose/project.py", line 403, in build
    build_service(service)
  File "/usr/local/lib/python3.6/dist-packages/compose/project.py", line 385, in build_service
    service.build(no_cache, pull, force_rm, memory, build_args, gzip, rm, silent, cli, progress)
  File "/usr/local/lib/python3.6/dist-packages/compose/service.py", line 1106, in build
    platform=self.platform,
  File "/usr/local/lib/python3.6/dist-packages/docker/api/build.py", line 160, in build
    path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/build.py", line 30, in tar
    files=sorted(exclude_paths(root, exclude, dockerfile=dockerfile[0])),
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/build.py", line 49, in exclude_paths
    return set(pm.walk(root))
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/build.py", line 214, in rec_walk
    for sub in rec_walk(cur):
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/build.py", line 184, in rec_walk
        for f in os.listdir(current_dir):
PermissionError: [Errno 13] Permission denied: '/etc/rasa/certs'

This happens when I try to build the custom image. Here is my Dockerfile:

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:1.10.0
USER root
# To install packages from PyPI
RUN pip3 install --no-cache-dir pytz==2019.3
USER 1001

And my docker-compose.override.yml is

version: '3.4'
services:
  rabbit:
    ports:
      - "5672:5672"
  app:
    # image: 'rasa/rasa-sdk:latest'
    build: 
      context: .
      dockerfile: Dockerfile
    volumes:
      - './actions:/app/actions'
      - './ressources:/app/ressources'
    expose:
      - '5055'

I tried several options but none of them seem to work. Do you know how I could fix this issue?

(I also did a issue on Github Error ‘Permission Denied’ using Docker to install custom dependencies · Issue #5789 · RasaHQ/rasa · GitHub)

Thanks a lot, Julien

Hi Julien, just checking are you building this image from the same server where you have deployed Rasa X? asking because of the location of the files whose permissions were denied. This looks like it’s a host machine problem, does the same thing work if you run it with sudo?

Yes I’m building the image on the same server where I deploy Rasa X. And with sudoit doesn’t do the same thing, and the image is built. So thank you a lot, but I don’t understand why I need sudo in the command line while I have USER root in my Dockerfile ?

EDIT : Now I have a error 502 (Bad Gateway) when I try to connect to Rasa X, and I see with docker-compose ps that is rasa_db_1 which doesn’t run. And I didn’t have this error the last time, it can be created by sudo command ?

Finally, the problem of Error 502 may come from something else, I re-install all, and this solution is good !

Thank you

Glad you got it working. The reason you needed sudo is because you need root permissions to build the image on the host machine , not inside your image, where user root is sufficient. Everything in /etc/rasa has specific permissions assigned to it at set up, so building your action image on the server where Rasa X is running, as it appears you are doing, can run into permissions issues with docker if you don’t use sudo to build the image. None of this will affect your image once it is built, though.