Sharing Ilmu

Sharing for useful things

Configure Persistent Storage Database server for container host in Linux Redhat/CentOS

In preceding tutorial I’m has been discuss about¬†Configure Persistent Storage web server for container host in Linux Redhat/CentOS and in this tutorial I will explain about configure persistent storage for database server in container.

Fist, create new directory in your home directory named as dbdir.

$ mkdir /home/user/dbdir

change permission of dbdir directory so that everyone has read/write permission access.

$ chmod 777 /home/user/dbdir

and then run new container for database with the following configuration :

Container name : mycondatabase

MYSQL USER : user1




Run new container for database

¬†$ podman run -d –name mycondatabase -p 3306:3306 -v ~/dbdir:/var/lib/mysql:Z -e MYSQL_USER=user1 -e MYSQL_PASSWORD=user123 -e MYSQL_DATABASE=mydb -e MYSQL_ROOT_PASSWORD=12345

Check the running podman with podman ps command

$ podman ps

Login to mysql database and check your database that have to create before :

exit from mysql, and then check the dbdir directory content

As the shown image above, those directory of dbdir has content that containing data of mysql database.

The configuration was successfull.

Leave a Reply

Your email address will not be published. Required fields are marked *.

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>