# Docker install fails with \_pycache\_ folder error

**URL:** <https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648>\
**Category:** Rasa Open Source\
**Created:** [November 24, 2019, 4:07pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648 "2019-11-24T16:07:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [November 24, 2019, 4:07pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/1 "2019-11-24T16:07:57Z")

</div>

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](https://github.com/RasaHQ/rasa/issues/4653). Maybe someone here has already solved this.

The error is the following:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [November 26, 2019, 8:20am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/2 "2019-11-26T08:20:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [November 27, 2019, 1:11pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/3 "2019-11-27T13:11:24Z")

</div>

@Tobias_WochingerI 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?

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [November 28, 2019, 9:22am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/4 "2019-11-28T09:22:50Z")

</div>

> 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 🙂 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.

---

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [November 30, 2019, 11:02pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/5 "2019-11-30T23:02:28Z")

</div>

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

> [@Tobias\_Wochinger](#):
>
> Also, for running in production, it’s better practice to avoid mounts and bake the model into the image.

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

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [December 2, 2019, 9:20am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/6 "2019-12-02T09:20:52Z")

</div>

> [@andileni](#):
>
> It definitely should be empty…

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!

---

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [December 2, 2019, 11:50am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/7 "2019-12-02T11:50:02Z")

</div>

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

```auto
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 🙂

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [December 2, 2019, 12:38pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/8 "2019-12-02T12:38:52Z")

</div>

> 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 🙂

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

---

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [December 2, 2019, 1:15pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/9 "2019-12-02T13:15:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dieterm](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@dieterm](https://forum.rasa.com/u/dieterm)\
**Post date:** [December 4, 2019, 9:50pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/10 "2019-12-04T21:50:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andileni](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andileni/32/5685_2.png) [@andileni](https://forum.rasa.com/u/andileni)\
**Post date:** [December 5, 2019, 2:07pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/11 "2019-12-05T14:07:36Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Arjaan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/arjaan/32/5754_2.png) [@Arjaan](https://forum.rasa.com/u/Arjaan)\
**Post date:** [December 24, 2019, 4:59pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/12 "2019-12-24T16:59:55Z")

</div>

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:

```auto
$ 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:

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

```

This [post](https://medium.com/@mccode/understanding-how-uid-and-gid-work-in-docker-containers-c37a01d01cf) is really nice to get clarity on how the uid is used in linux & docker.

---

<div class="post-metadata">

**Author:** ![skvis](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@skvis](https://forum.rasa.com/u/skvis)\
**Post date:** [February 13, 2020, 11:36am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/13 "2020-02-13T11:36:22Z")

</div>

Thanks this works for me

---

<div class="post-metadata">

**Author:** ![yiouyou](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/yiouyou/32/6821_2.png) [@yiouyou](https://forum.rasa.com/u/yiouyou)\
**Post date:** [February 22, 2020, 6:51am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/15 "2020-02-22T06:51:58Z")

</div>

@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?

```auto
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,

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [February 25, 2020, 8:49am UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/16 "2020-02-25T08:49:46Z")

</div>

> [@yiouyou](#):
>
> sudo docker run --user 0 -v $(pwd):/app rasa/rasa init

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

---

<div class="post-metadata">

**Author:** ![yiouyou](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/yiouyou/32/6821_2.png) [@yiouyou](https://forum.rasa.com/u/yiouyou)\
**Post date:** [February 25, 2020, 5:17pm UTC](https://forum.rasa.com/t/docker-install-fails-with-pycache-folder-error/21648/17 "2020-02-25T17:17:50Z")

</div>

Hi, @Tobias_Wochinger

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

> [@The inconsistant behaviors of Rasa X interactive model](http://forum.rasa.com/t/the-inconsistant-behaviors-of-rasa-x-interactive-model/25171):
>
> Dear community, Thanks to lots of posts, my 1st Rasa X is running, but it seems not right. As you can see below, when using the interactive model, the list of next action shows some actions which are not included in my trained model, such as “utter\_did\_that\_help”. Moreover, the actions showed in “Responses” page are not shown in the list, such as “utter\_askChange”, “utter\_ask\_movieName”,… and so on, even the “ticket\_form” defined in domain.yml file. Any idea why is th…

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?
