Docker Persistent Storage for MySQL Server and SELinux

Categories: Databases, tech

hello everyone today we will make

MySQL Docker Container with Shared Storage

first let’s pull latest MySQL  version of docker

after we did download the latest image

this image come in handy with some awesome parameters

  1. MYSQL_ROOT_PASSWORD
  2. MYSQL_DATABASE

with this  parameters, we can create a database and set root password for mysql

now let’s create a folder in our host so we can use it instead of /var/lib/mysql (let’s keep the mysql data in the host not inside a container)

remember it should be numeric formate

then we change the folder context to for selinux to  treat this as a virtualized sandbox

here we created a database called unixawy and root password un1x4wyp4ssw0rd

inspect your docker and connect to it IP

now each container you run with this command will share the same database data

check database content in your node storage via ls /var/mysql_data_store

cheers

«
»

    Leave a Reply

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

    *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.