Search code examples
dockerdocker-composeubuntu-20.04rasa

Permission denied while trying to access files in container during docker-compose(UBUNTU 20.04)


I am trying to work on a project which involves using rasa, when I run sudo docker-compose up , I get the following error .

Starting ask-my-doctor_rasa_1  ... done
Attaching to ask-my-doctor_ngrok_1, ask-my-doctor_rasa_1
rasa_1   | bash: line 15: /app/credentials.yml: Permission denied
rasa_1   | bash: line 16: /app/train_logs.txt: Permission denied
rasa_1   | bash: line 17: /app/run_actions_logs.txt: Permission denied
rasa_1   | 2021-06-07 14:02:52 DEBUG    rasa.telemetry  - Could not read telemetry settings from configuration file: Configuration 'metrics' key not found.
rasa_1   | 2021-06-07 14:02:52 WARNING  rasa.utils.common  - Failed to write global config. Error: [Errno 13] Permission denied: '/.config'. Skipping.
rasa_1   | 2021-06-07 14:02:53 DEBUG    rasa.cli.run  - 'models' not found. Using default location 'models' instead.
rasa_1   | Traceback (most recent call last):
rasa_1   |   File "/opt/venv/bin/rasa", line 8, in <module>
rasa_1   |     sys.exit(main())
rasa_1   |   File "/opt/venv/lib/python3.8/site-packages/rasa/__main__.py", line 117, in main
rasa_1   |     cmdline_arguments.func(cmdline_arguments)
rasa_1   |   File "/opt/venv/lib/python3.8/site-packages/rasa/cli/run.py", line 118, in run
rasa_1   |     args.model = _validate_model_path(args.model, "model", DEFAULT_MODELS_PATH)
rasa_1   |   File "/opt/venv/lib/python3.8/site-packages/rasa/cli/run.py", line 71, in _validate_model_path
rasa_1   |     os.makedirs(default, exist_ok=True)
rasa_1   |   File "/usr/lib/python3.8/os.py", line 223, in makedirs
rasa_1   |     mkdir(name, mode)
rasa_1   | PermissionError: [Errno 13] Permission denied: 'models'
ask-my-doctor_rasa_1 exited with code 1

I have also tried to just keep the container running and tried to login and create a file just to check and there as well I get the "permission denied" message.

How do I solve this permission issue?

Any help would be appreciated.


Solution

  • When using the docker-compose method to run Rasa, several folders will be mounted into the containers.

    I suspect that the group and permissions of the mounted directories are not correct.

    Can you please try this:

    # Go to root folder of your deployment folder.
    # Default is /etc/rasa, but from your error image, I see it is different.
    cd ~/Project/ask-my-doctor
    
    # Set group & permissions for everything in that folder
    sudo chgrp -R root * && sudo chmod -R 770 *
    
    # Correct group & permissions for the database
    sudo chown -R 1001 db && sudo chmod -R 750 /db
    

    A detailed explanation of these steps can be found in the rasa docs, for Linux/macOS users:

    The Rasa containers are following Docker’s best practices and are not running as root user. Hence, please make sure that the root group has read and write access to the following directories and their content:

    • /etc/rasa/credentials.yml
    • /etc/rasa/endpoints.yml
    • /etc/rasa/environments.yml
    • /etc/rasa/auth
    • /etc/rasa/certs
    • /etc/rasa/credentials
    • /etc/rasa/models
    • /etc/rasa/logs

    To set the permissions and group for everything in /etc/rasa you can use this command, but make sure to correct it for the /etc/rasa/db directory as described in the next step:

    sudo chgrp -R root /etc/rasa/* && sudo chmod -R 770 /etc/rasa/*
    

    If you are mounting different or extra directories, please adapt their permissions accordingly.

    Postgres Database Storage Configure persistent Postgres database storage

    On Linux, a local directory is used for persistent Postgres database storage. You must set the correct owner and permissions of the database persistence directory using this command:

    sudo chown -R 1001 /etc/rasa/db && sudo chmod -R 750 /etc/rasa/db