Podman Basic Usage:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| $ podman search rhel
$ podman pull $server/rhel7:7.5
$ podman images
$ podman run -d --name $node_name ubi7/ubi:7.7 echo 'Hello!'
$ podman run -d --name $node_name -it -e VAR=hi rhel /bin/bash
$ podman exec -it $node_name /bin/bash
$ podman exec -it -l /bin/bash
$ podman inspect -f '{{ .NetworkSettings.IPAddress }}' $node_name
$ podman ps --format "{{.ID}} {{.Image}} {{.Names}}"
$ podman ps -a
$ podman stop/restart/rm [-a]
$ podman logs $node_name
$ podman run -v $host_folder:$container_folder[:z] -p $host_ip:$host_port:$container_port
$ podman run -d -v $host_folder:$container_folder[:z] --net bridge IMAGE CMD
$ podman port $node_name
|
Podman macvlan
$ sudo podman network create –macvlan HOST_IFACE NETWORK_NAME
$ sudo cat /etc/cni/net.d/robot_network.conflist
{
“cniVersion”: “0.4.0”,
“name”: “NETWORK_NAME”,
“plugins”: [
{
“type”: “macvlan”,
“master”: “HOST_IFACE”,
“ipam”: {
“type”: “dhcp”
}
}
]
}%
$ sudo /usr/libexec/cni/dhcp daemon &
or
$ cat /usr/lib/systemd/system/io.podman.dhcp.socket
[Unit]
Description=DHCP Client for CNI
[Socket]
ListenStream=%t/cni/dhcp.sock
SocketMode=0600
[Install]
WantedBy=sockets.target
$ cat /usr/lib/systemd/system/io.podman.dhcp.service
[Unit]
Description=DHCP Client CNI Service
Requires=io.podman.dhcp.socket
After=io.podman.dhcp.socket
[Service]
Type=simple
ExecStart=/usr/libexec/cni/dhcp daemon
TimeoutStopSec=30
KillMode=process
[Install]
WantedBy=multi-user.target
Also=io.podman.dhcp.socket
$ sudo systemctl enable io.podman.dhcp.socket
$ sudo podman run -dt –name NODE_NAME –net NETWORK_NAME –cap-add net_raw –cap-add net_admin -v $host_folder:$container_folder[:z] docker.io/library/ubuntu:20.04 /bin/bash
Podman Images usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| $ podman images
$ podman save -o mysql.tar registry.access.redhat.com/rhscl/mysql-57-rhel7:5.7
$ podman load -i mysql.tar
$ podman rmi IMAGE
$ podman diff IMAGE_NAME
$ podman commit $node_name NEW_IMAGE_NAME[:tag]
$ podman tag IMAGE_NAME [user/]NAME:tag
$ podman rmi IMAGE:tag
$ podman push IMAGE [DESTINATION]
Dockerfile:
$ cat Dockerfile
FROM ubi7/ubi:7.7
MAINTAINER Your Name <youremail>
LABEL description="some description"
RUN yum install -y httpd && yum clean all
RUN echo "Hello from Dockerfile" > /var/www/html/index.html
EXPOSE 80
CMD ["httpd", "-D", "FOREGROUND"]
$ podman build --layers=false -t NAME:TAG DIR
|
Openshift cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| $ oc login -u USER -p PASS OCP_API
$ oc new-project PROJECT_NAME
$ oc new-app --as-deployment-config -i php:7.3 --context-dir DIR_NAME --name APP_NAME https://repo_addr
$ oc start-build APP_NAME
# expose svc to create route
$ oc expose svc/APP_NAME
$ oc delete route/APP_NAME
$ oc delete svc/APP_NAME
$ oc logs -f bc/APP_NAME
$ oc get pods
$ oc get svc/APP_NAME
$ oc get route/APP_NAME
# svc: services, dc: deployment config, bc: build config
|
Podman Selinux:
1
2
3
4
5
| # mkdir /tmp/tmp
# chown -R 27:27 /tmp/tmp
# semanage fcontext -a -t container_file_t '/tmp/tmp(/.*)?'
# restorecon -Rv /tmp/tmp
# ls -ldZ /tmp/tmp
|
Podman fedora
1
2
3
4
5
6
7
8
9
10
11
| $ podman pull quay.io/fedora/fedora:35-x86_64
$ podman run -d --name f35 -it $img_id /bin/bash
$ podman exec -it -l /bin/bash
$ podman ps -a
$ podman run -d --name debina -it 3a37950934ff /bin/bash
$ podman exec -it -l /bin/bash
# apt-get update
# apt-get install -y vim wget iproute2
$ podman stop -a
$ podman rm -a
|
Author
Hangbin Liu
LastMod
2023-08-25
(33e705c)