从另一个docker集装箱获取docker集装箱输出

我有一个应用程序通过docker run --rm ...运行dockerized命令。 是否有可能dockerize这个应用程序?

例如,我希望应用程序RUNNER运行应用程序RUNNABLE和读取标准输出结果。 (我需要asynchronous调用时尚RUNNABLE多个实例,但这是RUNNER应用程序业务)

我知道有可能只是将root访问权限导出到RUNNER应用程序的Docker套接字,但是这种感觉不正确。 特别是对于* nix应用程序没有根运行规则。

有没有其他的方法来沟通容器,而不是将套接字导出到容器? 我在做系统devise是否错误?

基本上可以让容器通过基于主机的文件进行通信。 看看下面的例子。

 # create a test dir mkdir -p docker_test/bin cd docker_test # an endless running script that writes output in a file vim bin/printDate.sh chmod 700 bin/*.sh # start docker container from debian image # the container got a local host mount of /tmp to container /opt/output # printDate.sh writes its output to container /opt/output/printDate.txt docker run --name cont-1 \ -v /tmp:/opt/output -it -v `pwd`/bin:/opt/test \ debian /opt/test/printDate.sh # start a second container in another terminal and mount /tmp again docker run --name cont-2 -v /tmp:/opt/output -it \ debian tail -f /opt/output/printDate.txt # the second container prints the output of program in cont-1 

容器1输出的无尽脚本

 #!/bin/bash while true; do sleep 1 date >> /opt/output/printDate.txt done