Podman : Create Pods2024/03/05 |
Create Pods like Kubernetes.
|
|
[1] | Create a Pod and add a Container to it. |
root@dlp:~ #
vi /usr/local/etc/containers/containers.conf # line 411 : add
infra_image = "k8s.gcr.io/pause:3.8"
# pull pause image root@dlp:~ # podman pull --os=linux k8s.gcr.io/pause:3.8
# create a empty pod # -p [bind port] -n [pod name] root@dlp:~ # podman pod create -p 8081:80 -n test-pod WARN[0000] image platform (linux/amd64) does not match the expected platform (freebsd/amd64) 198d74eb556be4e91a38594c7a32b5cd0397b999fb914e0fc283400101b86e58 # show pods root@dlp:~ # podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 198d74eb556b test-pod Created 15 seconds ago 5c76fd75bbe1 1 # show details of pod root@dlp:~ # podman pod inspect test-pod { "Id": "198d74eb556be4e91a38594c7a32b5cd0397b999fb914e0fc283400101b86e58", "Name": "test-pod", "Created": "2024-03-05T08:56:50.851623418+09:00", "CreateCommand": [ "podman", "pod", "create", "-p", "8081:80", "-n", "test-pod" ], "ExitPolicy": "continue", "State": "Created", "Hostname": "", "CreateCgroup": true, "CreateInfra": true, "InfraContainerID": "5c76fd75bbe12f1dec8341661fae79a94b5d5feb0e5b598fb64bf4a8f0c5fc8f", "InfraConfig": { "PortBindings": { "80/tcp": [ { "HostIp": "", "HostPort": "8081" } ] }, "HostNetwork": false, "StaticIP": "", "StaticMAC": "", "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": [ "podman" ], "NetworkOptions": null, "pid_ns": "private", "userns": "host", "uts_ns": "private" }, "SharedNamespaces": [ "ipc", "net", "uts" ], "NumContainers": 1, "Containers": [ { "Id": "5c76fd75bbe12f1dec8341661fae79a94b5d5feb0e5b598fb64bf4a8f0c5fc8f", "Name": "198d74eb556b-infra", "State": "created" } ], "security_opt": [ "unmask=all" ], "LockNumber": 51 }root@dlp:~ # podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/freebsd-nginx latest a0a053cc78a3 5 days ago 1.17 GB localhost/freebsd-httpd latest add46dedb2b7 5 days ago 1.44 GB localhost/freebsd-base latest 2527bfa5eeb4 6 days ago 1.05 GB quay.io/centos/centos stream9 ce3ac91d4020 2 weeks ago 161 MB docker.io/library/ubuntu latest 3db8720ecbf5 2 weeks ago 80.4 MB k8s.gcr.io/pause 3.8 4873874c08ef 20 months ago 718 kB # run container and add it to pod root@dlp:~ # podman run -dt --pod test-pod localhost/freebsd-nginx 434e30ffcdeb886702f744422f0b10667582c624b80bfca61c6ec98c05c795d8root@dlp:~ # podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5c76fd75bbe1 k8s.gcr.io/pause:3.8 About a minute ago Up 6 seconds 0.0.0.0:8081->80/tcp 198d74eb556b-infra 434e30ffcdeb localhost/freebsd-nginx:latest /usr/local/sbin/n... 6 seconds ago Up 6 seconds 0.0.0.0:8081->80/tcp jovial_taussig # verify accesses root@dlp:~ # ssh freebsd@node01.srv.world "curl -s http://`hostname`:8081" (freebsd@node01.srv.world) Password for freebsd@node01.srv.world: Dockerfile Test on Nginx # stop pod root@dlp:~ # podman pod stop test-pod 198d74eb556be4e91a38594c7a32b5cd0397b999fb914e0fc283400101b86e58 # remove pod (removed containers all) root@dlp:~ # podman pod rm test-pod --force 198d74eb556be4e91a38594c7a32b5cd0397b999fb914e0fc283400101b86e58 |
[2] | It's possible to create Pod and add Container with one command. |
root@dlp:~ # podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/freebsd-nginx latest a0a053cc78a3 5 days ago 1.17 GB localhost/freebsd-httpd latest add46dedb2b7 5 days ago 1.44 GB localhost/freebsd-base latest 2527bfa5eeb4 6 days ago 1.05 GB quay.io/centos/centos stream9 ce3ac91d4020 2 weeks ago 161 MB docker.io/library/ubuntu latest 3db8720ecbf5 2 weeks ago 80.4 MB k8s.gcr.io/pause 3.8 4873874c08ef 20 months ago 718 kB # create a [test-pod2] pod and add [localhost/freebsd-nginx] container root@dlp:~ # podman run -dt --pod new:test-pod2 -p 80:80 localhost/freebsd-nginx WARN[0000] image platform (linux/amd64) does not match the expected platform (freebsd/amd64) fa385d7050e61b7738356effb9e1bc7e8781f16b5e3a0fdd2179aa1cc24cae64root@dlp:~ # podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 5b07261b6ca0 test-pod2 Running 12 seconds ago 246b87d7c807 2root@dlp:~ # podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 246b87d7c807 k8s.gcr.io/pause:3.8 21 seconds ago Up 21 seconds 0.0.0.0:80->80/tcp 5b07261b6ca0-infra fa385d7050e6 localhost/freebsd-nginx:latest /usr/local/sbin/n... 21 seconds ago Up 21 seconds 0.0.0.0:80->80/tcp sharp_leavittroot@dlp:~ # ssh freebsd@node01.srv.world "curl -s http://`hostname`" (freebsd@node01.srv.world) Password for freebsd@node01.srv.world: Dockerfile Test on Nginx |
Sponsored Link |