Skip to content

Instantly share code, notes, and snippets.

@gmdias727
Forked from jclaret/podman_examples
Created October 26, 2022 01:25
Show Gist options
  • Save gmdias727/75d24b62f5229e018f85320ec699bda0 to your computer and use it in GitHub Desktop.
Save gmdias727/75d24b62f5229e018f85320ec699bda0 to your computer and use it in GitHub Desktop.
podman search rhel
podman pull rhel
podman images
podman run ubi7/ubi:7.7 echo "Hello!"
podman run -d rhscl/httpd-24-rhel7:2.4-36.8
curl http://10.88.0.68:8080
podman run -it ubi7/ubi:7.7 /bin/bash
podman run -e GREET=Hello -e NAME=RedHat rhel7:7.5 printenv GREET NAME
podman run --name mysql-custom -e MYSQL_USER=redhat -e MYSQL_PASSWORD=r3dh4t -d rhmap47/mysql:5.5
podman run --name mysql-basic \
> -e MYSQL_USER=user -e MYSQL_PASSWORD=mypass \
> -e MYSQL_DATABASE=database -e MYSQL_ROOT_PASSWORD=mypass \
> -d rhscl/mysql-57-rhel7:5.7-3.14
podman ps --format "{{.ID}} {{.Image}} {{.Names}}"
podman exec -it mysql-basic /bin/bash
mysql -uroot
mysql> show databases;
use database;
mysql> CREATE TABLE Projects (id int(11) NOT NULL,
-> name varchar(255) DEFAULT NULL,
-> code varchar(255) DEFAULT NULL,
-> PRIMARY KEY (id));
mysql> show tables;
mysql> insert into Projects (id, name, code) values (1,'Mola','001');
mysql> select * from Projects;
mysql> exit
podman run -d -p 8080:80 --name httpd-basic httpd:2.4
curl http://localhost:8080
podman exec -it httpd-basic /bin/bash
podman run rhscl/httpd-24-rhel7
podman ps
podman run --name my-httpd-container rhscl/httpd-24-rhel7
podman run --name my-httpd-container -d rhscl/httpd-24-rhel7
podman run rhscl/httpd-24-rhel7 ls /tmp
podman run -it rhscl/httpd-24-rhel7 /bin/bash
podman exec 7ed6e671a600 cat /etc/hostname
podman exec my-httpd-container cat /etc/hostname
podman exec -l cat /etc/hostname
podman inspect my-httpd-container
podman inspect -f '{{ .NetworkSettings.IPAddress }}' my-httpd-container
podman stop my-httpd-container
podman kill my-httpd-container
podman kill -s SIGKILL my-httpd-container
podman restart my-httpd-container
podman rm my-httpd-container
podman rm -a
podman stop -a
podman logs mysql-db
podman ps -a --format="table {{.ID}} {{.Names}} {{.Status}}"
mkdir -pv /var/local/mysql
semanage fcontext -a -t container_file_t '/var/local/mysql(/.*)?'
restorecon -R /var/local/mysql
ls -dZ /var/local/mysql
chown -Rv 27:27 /var/local/mysql
podman pull rhscl/mysql-57-rhel7
podman run --name persist-db \
> -d -v /var/local/mysql:/var/lib/mysql/data \
> -e MYSQL_USER=user1 -e MYSQL_PASSWORD=password \
> -e MYSQL_DATABASE=items -e MYSQL_ROOT_PASSWORD=r00tpa55 \
> rhscl/mysql-57-rhel7
podman ps --format="table {{.ID}} {{.Names}} {{.Status}}"
podman run -d --name apache3 -p 127.0.0.1::80 rhscl/httpd-24-rhel7:2.4
podman port apache3
/etc/containers/registries.conf
[registries.search]
registries = ["registry.access.redhat.com", "quay.io"]
[registries.insecure]
registries = ['localhost:5000']
curl -Ls https://myserver/v2/_catalog?n=3 | python -m json.tool
curl -Ls https://quay.io/bitnami/apache/tags/list | python -m json.tool
podman login -u username -p password registry.access.redhat.com
curl -u username:password -Ls "https://sso.redhat.com/auth/realms/rhcc/protocol/redhat-docker-v2/auth?service=docker-registry"
curl -H "Authorization: Bearer -Ls https://registry.redhat.io/v2/rhscl/mysql-57-rhel7/tags/list | python -mjson.tool
podman pull quay.io/bitnami/nginx
podman save -o mysql.tar registry.access.redhat.com/rhscl/mysql-57-rhel7:5.7
podman load -i mysql.tar
podman rm image
podman rmi -a
podman ps
podman diff mysql-basic
podman commit mysql-basic mysql-custom
podman tag mysql-custom devops/mysql
podman login quay.io
podman run -d --name official-httpd -p 8180:80 redhattraining/httpd-parent
podman exec -it official-httpd /bin/bash
podman inspect -f "{{range .Mounts}}{{println .Destination}}{{end}}" official-httpd
podman diff official-httpd
podman stop official-httpd
podman commit -a 'Your Name' official-httpd custom-httpd
podman images
# This is a comment
FROM ubi7/ubi:7.7
LABEL description="This is a custom httpd container image
MAINTAINER John Doe <[email protected]>
RUN yum install -y httpd
EXPOSE 80
ENV LogLevel "info"
ADD http://someserver.com/filename.pdf /var/www/html
COPY ./src/ /var/www/html/
USER apache
ENTRYPOINT ["/usr/sbin/httpd"]
CMD ["-D", "FOREGROUND"]
vi Dockerfile
FROM ubi7/ubi:7.7
MAINTAINER Your Name <youremail>
LABEL description="A basic Apache container on RHEL 7 UBI"
RUN yum install -y httpd && \
yum clean all
RUN echo "Hello from Dockerfile" > /usr/share/httpd/noindex/index.html
EXPOSE 80
ENTRYPOINT ["httpd", "-D", "FOREGROUND"]
podman build --layers=false -t example/apache .
podman images
podman run --name lab-apache -d -p 10080:80 do180/apache
podman ps
oc login
oc new-app \
> --docker-image=registry.access.redhat.com/rhscl/mysql-57-rhel7:latest \
> --name=mysql-openshift \
> -e MYSQL_USER=user1 -e MYSQL_PASSWORD=passwd -e MYSQL_DATABASE=testdb \
> -e MYSQL_ROOT_PASSWORD=root
oc status
oc get pods -o=wide
oc expose service mysql-openshift
oc port-forward mysql-openshift-1-glqrp 3306:3306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment