Skip to content

Instantly share code, notes, and snippets.

@9ightven0m
Created November 4, 2025 08:45
Show Gist options
  • Select an option

  • Save 9ightven0m/9cd04015d935487eff877670789947c0 to your computer and use it in GitHub Desktop.

Select an option

Save 9ightven0m/9cd04015d935487eff877670789947c0 to your computer and use it in GitHub Desktop.

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

🧩 1. Edit Your Shell Config

Open your shell’s config file:

  • For bash:

    nano ~/.bashrc
  • For zsh:

    nano ~/.zshrc

⚙️ 2. Add These Aliases

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
}

🔄 3. Reload Your Shell

Apply the new aliases:

source ~/.bashrc

(or source ~/.zshrc for Zsh)


🚀 4. Usage

Now you can simply type:

ubuntu

✨ What happens:

  • Creates ~/podman/ubuntu_data if 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 Ubuntu

Or from your host:

ubunt

🛑 Stops the container cleanly.


✅ 5. Summary

Command Action
ubuntu Auto-create and start persistent Ubuntu container
ubunt Stop it
Shared folder ~/podman/ubuntu_data/data inside Ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment