2017-12-06 23 views
0

docker run --rm ...でドッキングしたコマンドを実行するアプリケーションがあります。このアプリケーションをドッキングできますか?別のドッカーコンテナから出力されたドッキングコンテナを取得する

など。私はアプリRUNNERにアプリRUNNABLEを実行し、stdoutの結果を読ませたいと思います。 (私はファッションを呼び出して非同期にRUNNABLEの複数のインスタンスを必要とするが、それはRUNNERアプリケーションのビジネスだ)

私はそれがRUNNERアプリケーションへのドッキングウィンドウソケットにちょうど輸出ルートアクセスすることが可能である知っているが、これは右に感じることはありません。特に、* nixアプリケーションのルートを実行しないルールの場合

ソケットをコンテナにエクスポートするのではなく、コンテナを通信する方法はありますか?私は間違ったシステム設計をしていますか?

答えて

0

基本的には、コンテナにホストベースのファイルを介して通信させることができます。次の例を見てください。

# 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 
関連する問題