Containers Commands Notes
Containers Commands Notes
1.Podman run:
✅ Purpose
To create and start a container from a specified image, with options to manage:
Naming
Background execution
Port mapping
Cleanup behaviour
User permissions
✅ Common Options
Option Description
📌Example
🧪 Command
🔍 Explanation
Part Meaning
registry.access.redhat.com/ubi8/ubi:latest Use the Red Hat UBI 8 base image (latest tag)
🧾 Result
1
EX_188_Images related commands
Question: Does it combine the functionalities of both podman create and podman start
commands ?
Yes, exactly ✅
🔧 podman create
→ Creates a new container from an image, but does not start it.
▶️podman start
# Step 2: Start it
✅ Summary
Command Behavior
Use podman run when you want quick one-step execution. Use create + start when you
want more control or to configure the container before starting it.
2.Podman ps:
The podman ps command is used to list running containers on your system, similar to
docker ps.
🔍 Common Usage:
2
EX_188_Images related commands
Custom output format using Go templates.
📘 Example Output:
✅ Name: myApp
3.Podman stop:
🔧 What it does:
📘 Common Examples:
✅ Example Flow:
3
EX_188_Images related commands
If you ran:
4.Podman start:
The podman start command is used to start one or more stopped containers.
🔧 What it Does:
The container resumes execution with its last-known configuration (image, command,
ports, etc.).
📘 Common Examples:
🧠 Example Flow:
To confirm: podman ps
5.Podman restart:
The podman restart command is used to stop and then start one or more containers —
essentially performing a restart.
🔧 What it Does:
Useful when you want to refresh the container state or apply changes to mounted
volumes.
📘 Common Examples:
-t or --time: Time (in seconds) to wait before killing the container if it doesn't stop
gracefully.
🧠 Example Workflow:
Command Purpose
6.Podman rm:
The podman rm command is used to remove (delete) one or more stopped containers from
your system.
🔧 What It Does:
The container must be stopped before you can remove it, unless you use -f.
📘 Common Examples:
-f or --force: Stops the container first (if running), then removes it.
🧠 Example Flow:
5
EX_188_Images related commands
You previously ran: podman run -d --name myApp -p 8080:80
registry.access.redhat.com/ubi8/ubi:latest
⚠️Important Notes:
You cannot reuse the same container name (myApp) until it's removed.
Removing a container does not affect volumes, unless you explicitly mounted a
volume and want to clean it separately.
7. podman exec:
The podman exec command is used to run a command inside a running container.
🔧 What It Does:
Useful for inspecting or interacting with the container without logging in.
Often used to run tools like bash, sh, ls, cat, etc.
📘 Common Examples:
🟢 1. Run a shell inside the container: podman exec -it myApp /bin/bash
🔵 2. Run a single command inside the container: podman exec myApp ls /var/www
🧠 Example Flow:
Then you can enter the shell like this: podman exec -it myApp /bin/bash
Now you're "inside" the container and can inspect or debug it interactively.
🔄 Related Commands:
Command Purpose
6
EX_188_Images related commands
Command Purpose