summaryrefslogtreecommitdiff
path: root/contrib/python/examples/eg_attach.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/examples/eg_attach.py')
-rw-r--r--contrib/python/examples/eg_attach.py17
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.')