Skip to content

Instantly share code, notes, and snippets.

@dcode
Created November 19, 2018 20:55
Show Gist options
  • Save dcode/48f2325876a41f009de1356b59d712fc to your computer and use it in GitHub Desktop.
Save dcode/48f2325876a41f009de1356b59d712fc to your computer and use it in GitHub Desktop.
I brute forced playing through the options of podman to try to work with pods on a standalone system using podman (i.e. without kubernetes)
# Creates new pod named `test` with `running` status with `infra` container only
sudo podman pod create --name test
# Pauses the named pod and all containers in the pod
sudo podman pod pause test
# Unpauses the named pod and all containers in the pod
sudo podman pod unpause test
# Show all pods and their status
sudo podman pod ps
# Show all running processes across all containers in a pod
sudo podman pod top test
# Execute a command in a container assigned to a pod, detached from terminal
# Executes within the pod immediately, but will execute again if stopped once
# the pod is started
sudo podman run --pod test -d registry.fedoraproject.org/fedora:latest /usr/bin/sleep infinity
# Creates container in pod but does not execute until pod is started
sudo podman create --pod test --name bash4 registry.fedoraproject.org/fedora:latest /usr/bin/date
# Start a pod and all its containers
sudo podman pod start test
# Stop a pod and all its containers
sudo podman pod stop test
# Show live stats of all containers in running pods and their resource usage
sudo podman pod stats
################################################################################
## Working example
sudo podman pod create --name example
sudo podman create --pod example --name redis --hostname redis redis:alpine
sudo podman pod start example
sudo podman run -ti --pod example registry.fedoraproject.org/fedora:latest
# Redis is now listening and available in the fedora container on 127.0.0.1:6379
# By default all containers within a pod share the same network namespace,
# meaning anything listening on loopback is available across all containers in
# the pod
# I tested this with:
pip3 install aredis
curl -O https://raw.githubusercontent.com/NoneGG/aredis/master/examples/keys.py
# Should exit with status 0
python3 keys.py && echo $?
# Exit container
exit
# Stop the pod
sudo podman pod stop example
# Remove all containers in a pod
sudo podman rm $(sudo podman pod inspect example | jq -r '.Containers[] | .id')
# Remove the pod
sudo podman pod rm example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment