# Communicate Between Containers

**URL:** <https://forums.docker.com/t/communicate-between-containers/95927>\
**Category:** General\
**Tags:** dns, docker, build\
**Created:** [June 29, 2020, 4:24am UTC](https://forums.docker.com/t/communicate-between-containers/95927 "2020-06-29T04:24:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yf144114](https://avatars.discourse-cdn.com/v4/letter/y/db5fbb/32.png) [@yf144114](https://forums.docker.com/u/yf144114)\
**Post date:** [June 29, 2020, 4:24am UTC](https://forums.docker.com/t/communicate-between-containers/95927/1 "2020-06-29T04:24:47Z")

</div>

Please help if you know. **I am new to Docker**

I am working on a project that uses 2 different types of Containers.

**1. Apache Server Docker** (From ubuntu)  
Contains to be called _shell scripts and python scripts_  
**2. System Usage Docker** (From ubuntu)  
User enter interactive mode from here.

I am connecting both container’s network to host “–net host”, now I want to communicate between these 2 containers. Calling a script to start up from **docker 2** (System usage Docker) inside **docker 1** , is it possible to do it directly without using share volume or ssh method?

For example, inside **Docker 2** -it mode, I will do something like **" from docker 1 execute ./docker\_1.sh"** then this script will be running in **Docker 1**

Thanks for whoever willing to help.

---

<div class="post-metadata">

**Author:** ![yf144114](https://avatars.discourse-cdn.com/v4/letter/y/db5fbb/32.png) [@yf144114](https://forums.docker.com/u/yf144114)\
**Post date:** [June 29, 2020, 4:27am UTC](https://forums.docker.com/t/communicate-between-containers/95927/2 "2020-06-29T04:27:19Z")

</div>

Both docker 1 & 2 will be running at background, Docker 1 is using -d mode.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [June 29, 2020, 6:23am UTC](https://forums.docker.com/t/communicate-between-containers/95927/3 "2020-06-29T06:23:35Z")

</div>

> [@yf144114](#):
>
> is it possible to do it directly without using share volume or ssh method?

No, is not possible.

---

<div class="post-metadata">

**Author:** ![rofrano](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rofrano/32/27489_2.png) [@rofrano](https://forums.docker.com/u/rofrano)\
**Post date:** [July 8, 2020, 1:15am UTC](https://forums.docker.com/t/communicate-between-containers/95927/7 "2020-07-08T01:15:54Z")

</div>

Hi @yf144114, Containers are isolated from the host so it wouldn’t be able to run any scripts on the host. You would need to treat the host like a remote server and run an `sshd` daemon on the host so that the container can `ssh` to the host just like it can `ssh` to any other container or remote server. Of course you can use `rexec` or any other remote execution mechanism.

To answer your original question if this is achievable without `ssh` the answer is yes, but you would need to run some sort of server that can be communicated with via an API. One solution might be to run a Python Flask service on **docker 2** with a REST API that will run the script when the API is called from the **docker 1** container.
