# הפעלת פקודות rails מ-Bash המארח

**URL:** <https://meta.discourse.org/t/executing-rails-commands-from-host-bash/189126>\
**Category:** Self-hosting\
**Created:** [4 במאי,‏ 2021,‏ 11:04am UTC](https://meta.discourse.org/t/executing-rails-commands-from-host-bash/189126 "2021-05-04T11:04:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [4 במאי,‏ 2021,‏ 2:34pm UTC](https://meta.discourse.org/t/executing-rails-commands-from-host-bash/189126/4 "2021-05-04T14:34:46Z")

</div>

This is expected; you are telling docker to execute the binary `/usr/local/bin/rails console` in the container. That is, a single file with an embedded space. This file doesn’t exist.

consider the following:

```plaintext
○ → docker run -i debian /bin/echo hello
hello

○ → docker run -i debian '/bin/echo hello'
docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "/bin/echo hello": stat /bin/echo hello: no such file or directory: unknown.
ERRO[0000] error waiting for container: context canceled 

```

Quote the command the same way as if you were executing from inside the container:

```plaintext
○ → docker exec -i app rails runner 'puts "hello"'
hello

```

Using the example from the OP, this should work:

```plaintext
docker exec -i app rails runner 'UserDestroyer.new(Discourse.system_user).destroy(User.find_by_username_or_email("user@example.com"), delete_posts: false)'

```

---

_[View the full topic](https://meta.discourse.org/t/executing-rails-commands-from-host-bash/189126)._
