Docker install fails with _pycache_ folder error

Hello,

I tried to install rasa on my docker server. Unfortunately I get the following error when I follow the guide from the website.

I appreciate any help!

Update: This issue seems to be the same as described in [Docker] - Rasa init error · Issue #4653 · RasaHQ/rasa · GitHub. Maybe someone here has already solved this.

The error is the following:

root@XubuntuVM:~/rasaFolder# sudo docker run -v $(pwd):/app rasa/rasa init --no-prompt
Warning: Output is not to a terminal (fd=1).
Warning: Input is not to a terminal (fd=0).
Welcome to Rasa! �

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/distutils/dir_util.py", line 70, in mkpath
    os.mkdir(head, mode)
PermissionError: [Errno 13] Permission denied: '__pycache__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/build/bin/rasa", line 11, in <module>
    load_entry_point('rasa==1.5.0a1', 'console_scripts', 'rasa')()
  File "/build/lib/python3.6/site-packages/rasa/__main__.py", line 76, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/build/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 195, in run
    init_project(args, path)
  File "/build/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 111, in init_project
    create_initial_project(path)
  File "/build/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 119, in create_initial_project
    copy_tree(scaffold_path(), path)
  File "/usr/local/lib/python3.6/distutils/dir_util.py", line 159, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "/usr/local/lib/python3.6/distutils/dir_util.py", line 135, in copy_tree
    mkpath(dst, verbose=verbose)
  File "/usr/local/lib/python3.6/distutils/dir_util.py", line 74, in mkpath
    "could not create '%s': %s" % (head, exc.args[-1]))
distutils.errors.DistutilsFileError: could not create '__pycache__': Permission denied

@andileni What are your docker mounts? I guess the mounted volume does not have the correct permissions.

@Tobias_Wochinger I have a folder, lets say its named rasafolder, which I want to mount. I thought, I just enter the rasafolder directory and from there I run the command given in the documentation. Is this not the way I am supposed to do it?

I have a folder, lets say its named rasafolder, which I want to mount. I thought, I just enter the rasafolder directory and from there I run the command given in the documentation.

No, that’s right :slight_smile: But apparently your folder is not empty and the things in there have permissions which the user in the container does not have.

Also, for running in production, it’s better practice to avoid mounts and bake the model into the image.

@Tobias_Wochinger Thanks for your answer, the folder was created by me several seconds before trying to mount it. It definitely should be empty…

Is there somewhere a guide on how to do this in the rasa docs?

Ok, but what are the permissions / owner / group of the directory?

Is there somewhere a guide on how to do this in the rasa docs?

Unfortunately not. I’ll pass on your feedback!

@Tobias_Wochinger The command stat rasamount gave me the following permissions for this folder:

Access: (0775/drwxrwxr-x)  Uid: ( 1000/mainuser)   Gid: ( 1000/mainuser)

Possibly the userid 1000 is the problem, because in the dockerfile provided by rasa on github tasks are run with the userid 1001. Please correct me if I am wrong or on a wrong way :slight_smile:

Possibly the userid 1000 is the problem, because in the dockerfile provided by rasa on github tasks are run with the userid 1001. Please correct me if I am wrong or on a wrong way :slight_smile:

Yep, either make it accessible for user 1001 or for group 0

It is working now. I cloned the repository and changed the line in the dockerfile where the user ID is. After building a new image and starting the container the files are created as they should in the folder of my host.

We are having the same problem. What did you change the user to?

1 Like

I got the user-id of my non-root account with echo $UID and used this number to build the image. In my case the id was 1000, but I guess this depends on the linux system you use.
Hopefully this helps :slight_smile:

Instead of re-building the image, you can also just specify that the docker container must run as user 1000.

This is how it looks for me, on Ubuntu 18.04, when I am inside the folder where I will install the mood-bot:

$ stat .
  File: .
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d	Inode: 5119770     Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1000/  arjaan)   Gid: ( 1000/  arjaan)
Access: 2019-12-24 10:10:38.261990864 -0500
Modify: 2019-12-24 10:03:55.915369626 -0500
Change: 2019-12-24 10:03:55.915369626 -0500
 Birth: -

As you can see, access rights for the folder are for uid=1000.

So, running docker container as the user with uid=1000 will work:

sudo docker run --user 1000 -v $(pwd):/app rasa/rasa init --no-prompt

This post is really nice to get clarity on how the uid is used in linux & docker.

2 Likes

Thanks this works for me

@Tobias_Wochinger

Inside of test folder below, if run init command, I couldn’t get the trained model. It seems uid is 0, so “–user 0” is added to the command. But there’re still permission errors as blew. Any reason why?

root@ZZ:~/gitRepo/test# stat .
  File: .
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fc01h/64513d    Inode: 819226      Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-02-22 14:41:58.745536480 +0800
Modify: 2020-02-22 14:41:58.745536480 +0800
Change: 2020-02-22 14:41:58.745536480 +0800
 Birth: -

root@ZZ:~/gitRepo/test# sudo docker run --user 0 -v $(pwd):/app rasa/rasa init --no-prompt
Warning: Output is not to a terminal (fd=1).
Warning: Input is not to a terminal (fd=0).
Processed Story Blocks: 100%|██████████| 5/5 [00:00<00:00, 3918.45it/s, # trackers=1]

root@ZZ:~/gitRepo/test# ls
actions.py  core             data        endpoints.yml  __pycache__
config.yml  credentials.yml  domain.yml  __init__.py

root@ZZ:~/gitRepo/test# sudo docker run --user 0 -v $(pwd):/app rasa/rasa init
Welcome to Rasa! 🤖

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.
Now let's start! 👇🏽

Warning: Output is not to a terminal (fd=1).
Warning: Input is not to a terminal (fd=0).
Traceback (most recent call last):
  File "/build/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/build/lib/python3.6/site-packages/rasa/__main__.py", line 76, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/build/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 193, in run
    .skip_if(args.no_prompt, default=".")
  File "/build/lib/python3.6/site-packages/questionary/question.py", line 45, in ask
    return self.unsafe_ask(patch_stdout)
  File "/build/lib/python3.6/site-packages/questionary/question.py", line 59, in unsafe_ask
    return self.application.run()
  File "/build/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 736, in run
    return run()
  File "/build/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 710, in run
    return f.result()
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/future.py", line 151, in result
    raise self._exception
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 92, in step_next
    new_f = coroutine.throw(exc)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 685, in _run_async2
    result = yield f
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 88, in step_next
    new_f = coroutine.send(None)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 625, in _run_async
    with self.input.attach(read_from_input):
  File "/usr/local/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/input/vt100.py", line 150, in _attached_input
    loop.add_reader(fd, callback)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/posix.py", line 273, in add_reader
    self.selector.register(fd)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/select.py", line 78, in register
    sel.register(fd)
  File "/build/lib/python3.6/site-packages/prompt_toolkit/eventloop/select.py", line 133, in register
    self._sel.register(fd, selectors.EVENT_READ, None)
  File "/usr/local/lib/python3.6/selectors.py", line 412, in register
    self._epoll.register(key.fd, epoll_events)
PermissionError: [Errno 1] Operation not permitted

Thanks,

Can you please try with sudo docker run --user 0 -v $(pwd):/app rasa/rasa init --no-prompt?

Hi, @Tobias_Wochinger

The problem has been solved. Do you mind taking a look at this post, especially the last update?

What’s the difference between containers rasa-x_1, rasa-worker_1, and rasa-production_1? Based on docker-compose.yml, work_1 and production_1 are derived from x_1, but how they different when running Rasa X?