Reputation: 551
I would like to pipe the stdout of a script in container A to stdin of container B and then pipe stdout of container B to stdin of container C. I would like to know what is the best practice to do the same.
Option 1
docker run -it ImageA python script1.py | docker run -it ImageB python script2.py | \
docker run -it Image3 python script3.py
Option 2
Use a shared volume to store data that can be accessed by subsequent containers.
docker run -it -v /home/shared_volume:/container1_home/shared_volume python script1.py
docker run -it -v /home/shared_volume:/container2_home/shared_volume python script2.py
docker run -it -v /home/shared_volume:/container3_home/shared_volume python script3.py
Ideally, I prefer to not use shared volumes. The output of script1.py and script2.py produce intermediate files (or streams of data) that are in the order of several terabytes. I am not interested in these files, I would prefer to store only the results of script3.py to disk.
Upvotes: 3
Views: 1393
Reputation: 4880
Can you try the same by running it without -t option; I was able to do sample one like below and it is working
$docker run -i ubuntu:xenial ls -l | docker run -i ubuntu:xenial wc -l
$20
Upvotes: 1