<p><a href="https://stackoverflow.com/questions/32163955/how-to-run-shell-script-on-host-from-docker-container">This</a> StackOverflow question has answers that could be useful for you, in particular, mounting parts of the hosts filesystem containing the host application.</p>

<p>But really, it doesn't seem to make much sense to run an application in a container and then try to directly access the host system. It seems to defeat many of the reasons to containerize an application in the first place.</p>

<p>It'd probably much better to put the required application in the container, along with Django. I see no reason why your container wouldn't be able to run docker itself (even though for some CI/CD use cases sibling containers are <a href="https://stackoverflow.com/questions/27879713/is-it-ok-to-run-docker-from-inside-docker">preferred</a> over docker-in-docker approach).</p>

CC BY-SA 4.0
2020-01-17T20:16:16.237Z
You're right it doesn't make much sense. I wanted to dockerize the whole project so I could add a container orchestrastor, but the only issue is that one application. I've asked the developers of this application about dockerizing it, but they've tried and found it apparently made it unstable when using docker-in-docker. Maybe I should just wait and see into the future, maybe a solution might pop up. I appreciate you taking the time and answering my question though.
Super doe
CC BY-SA 4.0
2020-01-17T14:33:57.363Z
2020-01-17T14:33:57.363Z
Lykanion
<p>I'm in a situation where I have a Django application, Nginx webserver and Postgres database that I want to dockerize, and that's no issue I can do that. But the Django application has code that calls a subprocess to run a command from a installed program on the root host, and obviously if I run that command it's not recognized since it's not installed on the docker container.</p>

<p>The program can not be dockerized as far as I know, because it uses docker itself. Is there any way I can make the Django Application be able to run commands from that specific program on the root host, even though the Django application is containerized?</p>

<p>Can this be done through some kind of network setup of the docker container? </p>

<p>I find it a little hard to explain, so please do ask questions if something isn't clear enough.</p>

<docker><docker-compose>
Can I run command from a program thats based on the root host from a containerized application?
Super doe
# Can I run command from a program thats based on the root host from a containerized application?

(Asked by: username_0 on 2020-01-17)

I'm in a situation where I have a Django application, Nginx webserver and Postgres database that I want to dockerize, and that's no issue I can do that. But the Django application has code that calls a subprocess to run a command from a installed program on the root host, and obviously if I run that command it's not recognized since it's not installed on the docker container.

The program can not be dockerized as far as I know, because it uses docker itself. Is there any way I can make the Django Application be able to run commands from that specific program on the root host, even though the Django application is containerized?

Can this be done through some kind of network setup of the docker container?

I find it a little hard to explain, so please do ask questions if something isn't clear enough.

**Tags:** docker, docker-compose


---

## 1 answers

### Answer by username_1 on 2020-01-17. Score: 4 | Accepted answer

[This](https://stackoverflow.com/questions/32163955/how-to-run-shell-script-on-host-from-docker-container) StackOverflow question has answers that could be useful for you, in particular, mounting parts of the hosts filesystem containing the host application.

But really, it doesn't seem to make much sense to run an application in a container and then try to directly access the host system. It seems to defeat many of the reasons to containerize an application in the first place.

It'd probably much better to put the required application in the container, along with Django. I see no reason why your container wouldn't be able to run docker itself (even though for some CI/CD use cases sibling containers are [preferred](https://stackoverflow.com/questions/27879713/is-it-ok-to-run-docker-from-inside-docker) over docker-in-docker approach).

> **Comments:**
> **username_0**: You're right it doesn't make much sense. I wanted to dockerize the whole project so I could add a container orchestrastor, but the only issue is that one application. I've asked the developers of this application about dockerizing it, but they've tried and found it apparently made it unstable when using docker-in-docker. Maybe I should just wait and see into the future, maybe a solution might pop up. I appreciate you taking the time and answering my question though.  

---

