{%hackmd lTq14m8-RK6cksBvQ0Rnrg %}
# Podman
https://podman.io
Apache License 2.0
[TOC]
## Podman on Windows
### Install with executable file
Document: https://github.com/containers/podman/blob/main/docs/tutorials/podman-for-windows.md
### Install with Chocolatey
透過[Chocolatey套件管理](/s/5wV1nNxQSwaO5I0mkIT0Qw)進行安裝,開啟Administrator權限的PowerShell,執行以下指令
```powershell
> choco install podman-cli
```
### Initial VM(Podman Machine)
Podman安裝完成後開啟PowerShell,直接在預設路徑(C:\Users\User)
執行以下指令,進行Podman Machine的初始化
```powershell
PS > podman machine init
Downloading VM image: fedora-podman-amd64-v37.0.49.tar.xz: done
Extracting compressed file
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
正在匯入,這可能需要幾分鐘的時間。
操作順利完成。
Configuring system...
Generating public/private ed25519 key pair.
Your identification has been saved in podman-machine-default
Your public key has been saved in podman-machine-default.pub
Machine init complete
To start your machine run:
podman machine start
```
### Starting Machine
完成初始化後,執行以下指令啟動Podman Machine
```bash
PS > podman machine start
Starting machine "podman-machine-default"
This machine is currently configured in rootless mode.***If your containers
require root permissions (e.g. ports < 1024)***, or if you run into compatibility
issues with non-podman clients, you can switch using the following command:
podman machine set --rootful
API forwarding listening on: npipe:////./pipe/docker_engine
Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully
```
## Podman on MacOS
### Install
```bash=
$ brew install podman
```
### Start Podman VM
```bash=
$ podman machine init
Extracting compressed file
Image resized.
Machine init complete
To start your machine run:
podman machine start
$ podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /Users:/Users
Mounting volume... /private:/private
Mounting volume... /var/folders:/var/folders
This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:
podman machine set --rootful
API forwarding listening on: /Users/stan/.local/share/containers/podman/machine/qemu/podman.sock
The system helper service is not installed; the default Docker API socket
address can not be used by podman. If you would like to install it run the
following commands:
sudo /usr/local/Cellar/podman/4.5.1/bin/podman-mac-helper install
podman machine stop; podman machine start
You can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:
export DOCKER_HOST='unix:///Users/stan/.local/share/containers/podman/machine/qemu/podman.sock'
Machine "podman-machine-default" started successfully
```
### Stop Podman VM
```bash
$ podman machine stop
Machine "podman-machine-default" stopped successfully
```
### Uninstall
```bash=
$ brew uninstall podman
```
## First Podman Command
接下來可以進行一個簡單的測試,執行以下指令
> 透過這個範例會運行一個基於UBI8 Micro Image的容器,並執行 date 命令,得到終端機回覆容器內的時間
```bash
$ podman run ubi8-micro date
Resolved "ubi8-micro" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull registry.access.redhat.com/ubi8-micro:latest...
Getting image source signatures
Checking if image destination supports signatures
Copying blob sha256:07e0732da0346d7b04cccc63c31f85c8ed29becce6e84eccae660569cb568f4d
Copying config sha256:1de8feb0720bd6062160b7b0dd68593db13aa50614b9fcaf472d6c2d0856b5af
Writing manifest to image destination
Storing signatures
Thu Jul 6 06:18:58 UTC 2023
```
## Command
```
$ podman login docker.io
Username: umohnani
Password:
Login Succeeded!
```
#### Stopping Container
```bash
$ podman stop <containerId>
```
#### Stopping Pod
```bash
$ podman pod stop <podId>
```
#### Stopping Machine
```bash
$ podman machine stop
```
#### Removing Container
```bash
$ podman rm <containerId or containerName>
```
#### Removing Pod
```bash
$ podman pod rm <podId or podName>
```
#### Removing Machine
```bash
$ podman machine rm <machineName>
```
#### Display container configuration
```bash
$ podman inspect <containerId>
```
#### Others
查詢所有Podman提供可用的指令
```bash
$ podman --help
```
查詢所有指令可用的參數
```bash
$ podman <command> --help
```
## Trouble Shooting
[Trouble Shooting with Podman](/s/AWnRxsfSRqGgHmcEIQkZqg)