diff options
Diffstat (limited to 'contrib/python/examples/eg_attach.py')
-rw-r--r-- | contrib/python/examples/eg_attach.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/python/examples/eg_attach.py b/contrib/python/examples/eg_attach.py new file mode 100644 index 000000000..f8008163f --- /dev/null +++ b/contrib/python/examples/eg_attach.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +"""Example: Run Alpine container and attach.""" + +import podman + +print('{}\n'.format(__doc__)) + +with podman.Client() as client: + id = client.images.pull('alpine:latest') + img = client.images.get(id) + cntr = img.create() + cntr.start() + + try: + cntr.attach() + except BrokenPipeError: + print('Container disconnected.') |