Skip to content
/ mypy Public

Example I/O streaming with Docker and Python

Notifications You must be signed in to change notification settings

miladhub/mypy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python I/O redirection with Docker example

Toy project experimenting how to use a Python app inside a Docker container to stream commands via STDIN and receive responses via STDOUT, just like you would do with a local Python app.

This might help in deciding how to invoke apps embedded with Docker.

Local invocation

Just for reference, this is what I want to achieve:

$ cat | python3 my.py 
1 2 3
6
10 20 30
60
^CTraceback (most recent call last):
  File "my.py", line 11, in <module>
      for line in sys.stdin:
      KeyboardInterrupt
      my.py 

Building the Docker image

docker build -t mypy .

Invoking it

$ cat | docker run --rm -i mypy 
1 2 3
6
10 20 30
60
^CTraceback (most recent call last):
  File "my.py", line 12, in <module>
    for line in sys.stdin:
KeyboardInterrupt

About

Example I/O streaming with Docker and Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published