Podman is container runtime engine like docker, Rocket, Drawbridge, LXC.
podman login -u username -p password registry.access.redhat.compodman pull [OPTIONS] [REGISTRY[:PORT]/]NAME[:TAG]podman ps -apodman search <image-name>
podman pull <image-name>
podman images
podman run <image-name> echo 'Hello world!'
podman run -d -p 8080 httpd << Run a container with image httpd in background with -d
podman port -l << Displays port details of last used container
podman run -it ubi8/ubi:8.3 /bin/bash << Run and enter to bash of a container with -it
podman run --name MySQL-custom \
-e MYSQL_USER=Ruser -e MYSQL_PASSWORD=PASS \
-e MYSQL_ROOT_PASSWORD= PASS \
-d MySQL
podman ps --format "{{.ID}} {{.Image}} {{.Names}}"
Root and Rootless Containers
sudo podman run --rm --name asroot -ti httpd /bin/bashpodman run --rm --name asuser -ti httpd /bin/bashpodman run --name my-httpd-container httpd << Custom name to pod with --namepodman exec httpd-container cat /etc/hostname << Running commands in container with execpodman stop my-httpd-containerpodman kill -s SIGKILL my-httpd-container << send custom kill signals by -spodman restart my-httpd-containerpodman rm my-httpd-containerpodman rm -a << Remove all podspodman stop -a << Stop all podspodman exec mysql /bin/bash -c 'mysql -uuser1 -pmypa55 -e "select * from items.Projects;"'
Sharing a local directory to container.
First setup the local directory with proper selinux permission
mkdir /home/student/dbfilespodman unshare chown -R 27:27 /home/student/dbfiles <<sudo semanage fcontext -a -t container_file_t '/home/student/dbfiles(/.*)?'sudo restorecon -Rv /home/student/dbfilesls -ldZ /home/student/dbfilesThe mount the path with -v location_in_local:location_in_containerpodman run -v /home/student/dbfiles:/var/lib/mysql rhmap47/mysqlpodman unshare chown 27:27 /home/student/local/mysql
Port management
podman run -d --name apache1 -p 8080:8080 httpdpodman run -d --name apache2 -p 127.0.0.1:8081:8080 httpdpodman run -d --name apache3 -p 127.0.0.1::8080 httpdpodman port apache3
Podman Image Management
Podman is available on a RHEL host with the following entry in /etc/containers/
registries.conf file:
[registries.search]registries = ["registry.redhat.io","quay.io"]podman save [-o FILE_NAME] IMAGE_NAME[:TAG]podman save -o mysql.tar quay.io/mysql:latestpodman load [-i FILE_NAME]podman load -i mysql.tarpodman rmi [OPTIONS] IMAGE [IMAGE...]podman rmi -apodman commit [OPTIONS] CONTAINER [REPOSITORY[:PORT]/]IMAGE_NAME[:TAG]podman commit mysql-basic mysql-custompodman commit -a 'Your Name' httpd httpd-new
podman diff container-name << diff subcommand tags any added file with an A, any changed ones with a C, and any deleted
file with a D.
podman tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]podman tag mysql-custom devops/mysqlpodman rmi devops/mysql:snapshotpodman push [OPTIONS] IMAGE [DESTINATION]podman push quay.io/bitnami/nginx
No comments:
Post a Comment