My notes on how to use podman.

 

--- Install podman --- [root@localhost ~]# yum install podman slirp4netns --- To login to registry.redhat.io so that you can download container images --- --- if you use registry.access.redhat.com instead, you don't have to login --- [root@server01 ~]# podman login registry.redhat.io --- Download a container image --- [root@server01 ~]# podman pull registry.redhat.io/rhscl/httpd-24-rhel7 [root@localhost ~]# podman pull registry.access.redhat.com/rhscl/mariadb-102-rhel7 [root@localhost ~]# podman pull registry.access.redhat.com/rhscl/php-71-rhel7 --- Create and start a container --- [root@server01 ~]# podman run -d -P registry.redhat.io/rhscl/httpd-24-rhel7 -- Start a container -- [root@server01 ~]# podman start <contain_name> --- List running containers --- [root@server01 ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb87ff77425d registry.redhat.io/rhscl/httpd-24-rhel7:latest /usr/bin/run-http... 4 minutes ago Up 4 minutes ago 0.0.0.0:46843->8080/tcp, 0.0.0.0:35687->8443/tcp hardcore_khayyam --- Start the bash shell in the given container --- [root@server01 ~]# podman exec -it fb87ff77425d bash bash-4.2$ echo "hello from my container" > /var/www/html/index.html bash-4.2$ exit --- Get the IP Address of a given container --- [root@server01 ~]# podman inspect -f "{{.NetworkSettings.IPAddress}}" fb87ff77425d 10.88.0.31 --- List the ports allowed to pass through to the last used container (-l) --- --- change the -l to -a to list for all running containers --- [root@server01 ~]# podman port -l 8080/tcp -> 0.0.0.0:46843 8443/tcp -> 0.0.0.0:35687 --- List all container images on the local system --- [root@server01 ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi8/ubi latest 0c46e5c7a82a 2 days ago 239 MB registry.redhat.io/rhel8/nginx-114 latest 7b386b0cb891 5 weeks ago 407 MB registry.redhat.io/rhel8/rsyslog latest 291836dcc008 5 weeks ago 259 MB registry.redhat.io/rhscl/httpd-24-rhel7 latest 54a9312811c3 5 weeks ago 329 MB registry.redhat.io/rhel7 latest 2ef6ad3f3825 5 weeks ago 215 MB --- Stop a container --- [root@server01 ~]# podman stop a2ecc1f73aff --- A sample of a more complex run command --- [root@server01 ~]# podman run --ip 10.xx.xx.xx -p 3306:3306 --name mariadb-service -v /opt/var/lib/mysql/data:/var/lib/mysql/data:Z -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=mysecret -e MYSQL_DATABASE=wordpress registry.access.redhat.com/rhscl/mariadb-102-rhel7 or podman run --detach --tty --volume /tmp/html:/usr/local/apache2/htdocs -p 80:80/tcp --name apache_container docker.io/library/httpd --- Inspect a container image for various information --- [root@localhost ~]# podman inspect registry.access.redhat.com/rhscl/mariadb-102-rhel7 | grep User [root@localhost ~]# podman inspect registry.access.redhat.com/rhscl/mariadb-102-rhel7 | grep -A1 Volume [root@localhost ~]# podman inspect registry.access.redhat.com/rhscl/mariadb-102-rhel7 | grep -A1 ExposedPorts -- Reference URLS --- https://developers.redhat.com/blog/2018/11/29/managing-containerized-system-services-with-podman/ https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/building_running_and_managing_containers/index

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer