$ podman search mysql
NAME DESCRIPTION
registry.access.redhat.com/rhscl/mysql-56-rhel7 MySQL 5.6 SQL database server
registry.access.redhat.com/rhscl/mysql-57-rhel7 Docker image for running MySQL 5.7 server. This image can provide database
registry.access.redhat.com/rhscl/mysql-80-rhel7 This container image provides a containerized packaging of the MySQL mysqld
$ podman run -d --name mysql-80-rhel7 \
-p 13306:3306 \
-e MYSQL_ROOT_PASSWORD=redhat123 \
-e MYSQL_DATABASE=items \
-e MYSQL_USER=myuser \
-e MYSQL_PASSWORD=redhat123 \
registry.access.redhat.com/rhscl/mysql-80-rhel7
$ podman exec mysql-80-rhel7 ps -aux | grep mysql
mysql 1 0.9 20.2 1616588 303784 ? Ssl 11:30 0:00 /opt/rh/rh-mysql80/root/usr/libexec/mysqld --defaults-file=/etc/my.cnf
$ podman exec mysql-80-rhel7 id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql),0(root)
$ podman exec mysql-80-rhel7 cat /etc/my.cnf.d/base.cnf
[mysqld]
datadir = /var/lib/mysql/data
...
$ podman stop mysql-80-rhel7
$ podman rm mysql-80-rhel7
$ mkdir /home/student/mysql-80-rhel7
$ podman unshare chown -R 27:27 /home/student/mysql-80-rhel7
$ podman run -d --name mysql-80-rhel7 \
-p 13306:3306 \
-e MYSQL_ROOT_PASSWORD=redhat123 \
-e MYSQL_DATABASE=items \
-e MYSQL_USER=myuser \
-e MYSQL_PASSWORD=redhat123 \
-v /home/student/mysql-80-rhel7:/var/lib/mysql/data:Z \
registry.access.redhat.com/rhscl/mysql-80-rhel7
$ podman logs mysql-80-rhel7
$ vim db.sql
CREATE TABLE items.product (id int NOT NULL, name varchar(255) DEFAULT NULL, PRIMARY KEY (id));
INSERT INTO items.product (id, name) VALUES (1,'Bar');
SELECT * FROM items.product;
$ podman cp db.sql mysql-80-rhel7:/tmp
$ podman exec mysql-80-rhel7 /bin/bash -c \
'mysql --host=127.0.0.1 --port=3306 --database=items --user=myuser --password=redhat123 < /tmp/db.sql'
$ podman exec mysql-80-rhel7 /bin/bash -c \
"mysql --host=127.0.0.1 --port=3306 --database=items --user=myuser --password=redhat123 --execute='SELECT * FROM items.product';"
$ podman stop mysql-80-rhel7; podman rm mysql-80-rhel7
$ ls -aldZ /home/student/mysql-80-rhel7
drwxr-xr-x. 3 296634 296634 system_u:object_r:container_file_t:s0:c493,c605 102 Jul 25 13:40 /home/student/mysql-80-rhel7
I'm dedicated agile security architect/system architect/developer with specialty of open source framework.
July 27, 2022
OpenShift 4.10 I: Container mysql with Persistent Storage, Unshare and SELinux
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment