0

I have two linux docker containers: * ContainerA - tomcat image - running a java app * ContainerB - ubuntu image - execution of shell script runs a CLI linux application

ContainerA doesn't have busybox hence can't run the shell script, and needs to be seperated from the linux app due to large filesize - hence two docker containers.

I'm trying to call from ContainerA the shell script which in ContainerB, but can't access it.

  1. Was looking into --links but it's not networking. I'm confused how to proceed or in making it work.
5
  • What is the shell script meant to do? Commented May 14, 2019 at 16:26
  • @bellackn the shell script is an executable program in ContainerB. It's math calculation application - ContainerA needs to call it so it can send over formulas to run and then receive back response. Commented May 14, 2019 at 16:41
  • 1
    You would need an API on your container B to which container A could talk to. There is no simple Docker way to execute scripts in sibling containers. Just think of how you would solve this if your two containers were two different remote machines that would have to exchange data over network. Your problem is probably of similar nature. Commented May 14, 2019 at 16:48
  • @bellackn what sort of API? and how would I request from containerA ? Commented May 14, 2019 at 16:57
  • You can request resources on your container B via HTTP (among others). For this, you would need a service in container B (the API) that your container A can talk to via HTTP. The API can be built however you like (e.g.with Flask if you like Python). Commented May 14, 2019 at 17:04

1 Answer 1

1

As I've already pointed out in the comments, this is something you won't find a simple OOTB Docker solution for. Containers usually talk to each other via networking protocols (HTTP) and are therefore not so different from actual, spatially divided machines. So, you would need an API on your container B that returns the resource that you want to the requesting end (container A in your case). APIs can be built in numerous ways; I've already mentioned Flask for Python. Jersey seems to be a similar framework for Java.

Implementing this is not done in a breeze, but I don't see how to approach this in another way, besides rethinking your setup as a whole.

Sign up to request clarification or add additional context in comments.

2 Comments

is there no way to call via CLI, e.g. containerip:app/dir ?
You could fashion something with SSH/SCP, I guess. But no, as I said, there is no native Docker solution that I know of.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.