2017-12-06 9 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 
관련 문제