Podman : Create Pods2025/04/22 |
Create Pods like Kubernetes. |
|
[1] | Create a Pod and add a Container to it. |
# create a empty pod # -p [bind port] -n [pod name] root@dlp:~# podman pod create -p 8081:80 -n test-pod 8b8dabfc20cbe1c5469731f4a3822fce2c49c55f0a5992a0fd8b0395ceacf0ed # show pods root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 8b8dabfc20cb test-pod Created 15 seconds ago 2d7614034c46 1 # show details of pod root@dlp:~# podman pod inspect test-pod [ { "Id": "8b8dabfc20cbe1c5469731f4a3822fce2c49c55f0a5992a0fd8b0395ceacf0ed", "Name": "test-pod", "Created": "2025-04-22T00:40:13.581578131Z", "CreateCommand": [ "podman", "pod", "create", "-p", "8081:80", "-n", "test-pod" ], "ExitPolicy": "continue", "State": "Created", "Hostname": "", "CreateCgroup": true, "CgroupParent": "machine.slice", ..... .....root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.1-1742477809 1b9916037b93 58 seconds ago 793 kB docker.io/library/root-web latest c65d1e928abe 6 minutes ago 137 MB srv.world/iproute latest e9449427b6fe 13 minutes ago 135 MB srv.world/ubuntu-nginx latest 1fbf2477f02c 40 minutes ago 137 MB srv.world/ubuntu-apache2 latest b7f1351d1b3c 47 minutes ago 246 MB docker.io/library/ubuntu latest 602eb6fb314b 13 days ago 80.6 MB docker.io/moby/buildkit buildx-stable-1 3c2d38015344 4 weeks ago 209 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 MB # run container and add it to pod root@dlp:~# podman run -dt --pod test-pod srv.world/ubuntu-nginx 730e087d48f1d94f6f21c0538f16d738c48dc9be17105a40aa5d58045a249235root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d7614034c46 localhost/podman-pause:5.4.1-1742477809 About a minute ago Up 12 seconds 0.0.0.0:8081->80/tcp 8b8dabfc20cb-infra 730e087d48f1 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 12 seconds ago Up 12 seconds 0.0.0.0:8081->80/tcp boring_wu # verify accesses root@dlp:~# curl localhost:8081 Podman Test on Nginx # stop pod root@dlp:~# podman pod stop test-pod test-pod # remove pod (removed containers all) root@dlp:~# podman pod rm test-pod --force 8b8dabfc20cbe1c5469731f4a3822fce2c49c55f0a5992a0fd8b0395ceacf0ed |
[2] | It's possible to create Pod and add Container with one command. |
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.1-1742477809 1b9916037b93 3 minutes ago 793 kB docker.io/library/root-web latest c65d1e928abe 9 minutes ago 137 MB srv.world/iproute latest e9449427b6fe 16 minutes ago 135 MB srv.world/ubuntu-nginx latest 1fbf2477f02c 42 minutes ago 137 MB srv.world/ubuntu-apache2 latest b7f1351d1b3c 49 minutes ago 246 MB docker.io/library/ubuntu latest 602eb6fb314b 13 days ago 80.6 MB docker.io/moby/buildkit buildx-stable-1 3c2d38015344 4 weeks ago 209 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 MB # create a [test_pod2] pod and add [srv.world/ubuntu-nginx] container root@dlp:~# podman run -dt --pod new:test-pod2 -p 80:80 -p 3306:3306 srv.world/ubuntu-nginx e9b772e845c78315352f9405afa009238f1872c8ca504e154decc6ee972da2f7root@dlp:~# podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 3f204073fb07 test-pod2 Running 14 seconds ago 276692d7a9ac 2root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 276692d7a9ac localhost/podman-pause:5.4.1-1742477809 27 seconds ago Up 27 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 3f204073fb07-infra e9b772e845c7 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 27 seconds ago Up 27 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp xenodochial_chaplygin # run [mariadb] container and add it to the [test-pod2] root@dlp:~# podman run -dt --pod test-pod2 -e MYSQL_ROOT_PASSWORD=Password docker.io/library/mariadb 9f8f6bd7bbe963f5a4d27167484919a0c92316f340ee653e7498033a626ad7e1root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 276692d7a9ac localhost/podman-pause:5.4.1-1742477809 About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp 3f204073fb07-infra e9b772e845c7 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp xenodochial_chaplygin 9f8f6bd7bbe9 docker.io/library/mariadb:latest mariadbd 10 seconds ago Up 11 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:3306->3306/tcp hardcore_goldberg
root@dlp:~#
root@dlp:~# curl dlp.srv.world Dockerfile Test on Nginx mysql -u root -p -h dlp.srv.world -e "show variables like 'hostname';" Enter password: +---------------+-----------+ | Variable_name | Value | +---------------+-----------+ | hostname | test-pod2 | +---------------+-----------+ |
Sponsored Link |