RedHat - chanandrew96/MyLearning GitHub Wiki
RedHat使用yum
來安裝套件
sudo yum install <Package-Name>
yum install git
yum install python3
yum install python3-pip
- 列出所有Images
podman image ls
- 列出所有Container
podman ps -a
- 停止正在運行的Container
podman stop <Container-ID/Container-Name>
- 刪除Container
podman rm <Container-Name>
- 列出所有Pod (Pod類近Stack,可包含多個Container)
podman pod list
- 刪除Pod
podman pod rm <Pod-Name>
- 使用已知的Image來建立和啟動Container
podman run <Image-Name> -e <Parameter-Name>='<Parameter-Value>' -e <Parameter-Name>='<Parameter-Value>'
使用-v
的時候有可能在運行Pod的時候出現Access Denied的問題,可用以下其中一個解決方式
- 在
podman run
或podman create
中加上--security-opt label=disable
例子:
podman run -it --rm -v /var/data:/sqm --security-opt label=disable docker.io/library/alpine sh
- 在
-v
後加上:Z
例子:
podman run -it --rm -v /var/data:/sqm:Z docker.io/library/alpine sh
使用YAML可以同時建立多個Container,會把這些Container放到同一個Pod中
apiVersion: v1
kind: Pod
metadata:
name: Form-Recognzier
spec:
containers:
- name: container-1
image: container-image-1
ports:
- containerPort: 5000
hostPort: 5000
protocol: TCP
env:
- name: Parameter-1
value: Value-1
使用命令podman play kube <YAML-File-Name>
執行預先寫好的YAML檔案
使用podman kube down <YAML-File-Name>
來停止及刪除由yml
檔建立的Container
當你刪除由這個檔案建立的Pod時,其相關的Container也會用時刪除
yum install python3-pip
pip install podman-compose
根據這網站的教學,我們在直接使用Podman-compose來執行Docker-compose的yml
檔案前我們需要安裝podman-plugins
& dnsmasq
yum install podman-plugins
podman-compose -f <yml-file> up -d
設定Port Forwarding
sudo firewall-cmd --add-forward-port=port=<Port-Number>:proto=<Protocol>:toport=<To-Port-Number>
sudo firewall-cmd --add-forward-port=port=8080:proto=tcp:toport=8080
如果在yml
檔中使用了${}
的方法來取得.env
檔中的數值,我們可以以下面的命令更新並取得帶有數值的yml
檔用於轉換
記得需要把.env檔放於yml檔的相同路徑
docker compose -f <original-yml-file> config > <output-yml-file>
kompose convert -f <Docker-Compose-yml-file>
- 將CA Cert放到
/etc/pki/ca-trust/source/anchors
- 執行
update-ca-trust extract
更新CA Trust列表 - 查看現有CA Trust
trust list | grep <Cert>
- 如果未能成功使用SSL連線,可以嘗試
update-ca-trust extract --anchor <.crt>
openssl verify <.crt>
openssl s_client -connect <cert.page:port> -CAfile <.crt>
curl -v --cacert <.crt> <https://link:port>
- 修改
/etc/hosts
檔案 - 加上新的Mapping
192.168.0.101 new-device