Perfect 🔥 — we'll be running and making ubuntu alias fully self-contained:
- It’ll auto-create shared folder (
~/podman/ubuntu_data) on your main OS - Create the container if it doesn’t exist
- Then drop you right into Bash inside your persistent Ubuntu environment
Open your shell’s config file:
-
For bash:
nano ~/.bashrc -
For zsh:
nano ~/.zshrc
Paste this block at the end of the file:
# === Ubuntu Container Shortcuts ===
alias ubunt='podman stop ubuntu_persistent >/dev/null 2>&1 && echo "🛑 Ubuntu container stopped."'
ubuntu() {
CONTAINER_NAME="ubuntu_persistent"
HOST_DIR="$HOME/podman/ubuntu_data"
# Create shared folder if missing
[ -d "$HOST_DIR" ] || mkdir -p "$HOST_DIR"
# Check if container exists
if ! podman container exists "$CONTAINER_NAME"; then
echo "🚀 Creating new Ubuntu container..."
podman run -dit --name "$CONTAINER_NAME" -v "$HOST_DIR":/data ubuntu >/dev/null
fi
# Start container if it’s not running
if [ "$(podman inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
podman start "$CONTAINER_NAME" >/dev/null
fi
# Drop into Bash shell
podman exec -it "$CONTAINER_NAME" bash
}Apply the new aliases:
source ~/.bashrc(or source ~/.zshrc for Zsh)
Now you can simply type:
ubuntu✨ What happens:
- Creates
~/podman/ubuntu_dataif it doesn’t exist - Creates your persistent container (if missing)
- Starts it if stopped
- Opens a bash shell inside it
When you’re done:
exit # exits UbuntuOr from your host:
ubunt🛑 Stops the container cleanly.
| Command | Action |
|---|---|
ubuntu |
Auto-create and start persistent Ubuntu container |
ubunt |
Stop it |
| Shared folder | ~/podman/ubuntu_data ↔ /data inside Ubuntu |