I am running a Ubuntu 20.04.5 LTS virtual machine for my development environment. In the past I have run multiple VM's to host databases, web servers, etc, as I need them for projects. So in short, I am a container noob!
What I am attempting to do is to create ONE Ubuntu virtual machine running Podman containers.
My current blocker is MySQL, or any other RDB.
If I use the container default locations for storage, I will need to load a new database dump every time I start up the container, since storage is, by nature ephemeral. This is clearly not ideal.
I have read, many use cases that specify creating an attached or mounted drive/directory to store the MySQL directories so that the data does not disappear after every restart of the container. What I have NOT found is how to set that up correctly.
Again, my goal is to mount a HOST directory as the MySQL data dir.
So first, I created a shared data location with completely open permissions:
echo "STATUS: Creating data directory for MySQL container"
sudo mkdir -p /opt/mysql/server/data
sudo chmod 777 /opt/mysql -R
Then I mapped the drive and specified the data directory:
echo "STATUS: Run container with mapped host drive"
podman run -d --replace --name=MySQL -h=mysql-pod -p=63306:3306 /
-v="/opt/mysql/server:/var/lib/mysql" docker.io/mysql/mysql-server:8.0 /
--basedir=/var/lib/mysql --datadir=/var/lib/mysql/data
Executing this command leaves me with the following log entries:
podman:/vagrant/podman$ podman logs MySQL
[Entrypoint] MySQL Docker Image 8.0.30-1.2.9-server
2022-09-14T23:03:17.922048Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/var/lib/mysql/share/mysql-8.0/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
[Entrypoint] Initializing database
[Entrypoint] No password option specified for new database.
[Entrypoint] A random onetime password will be generated.
mysqld: Can't create/write to file '/var/lib/mysql/data/is_writable' (OS errno 13 - Permission denied)
2022-09-14T23:03:17.954340Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2022-09-14T23:03:17.954386Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.30) initializing of server in progress as process 12
2022-09-14T23:03:17.954403Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/var/lib/mysql/share/mysql-8.0/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2022-09-14T23:03:17.954836Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting.
2022-09-14T23:03:17.954840Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/data/ is unusable. You can remove all files that the server added to it.
2022-09-14T23:03:17.954859Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-09-14T23:03:17.954918Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
I have tried multiple permission sets, creating a mysql user on the host and giving it the directory ownership... and a bunch of other things, because I can't find a good explanation of how to do this correctly.
Again, I am a container noob so I am pretty sure I am missing something regarding the shared resource permissions, but I have been through a hundred iterations of mapping and permissions and have not found anything online that addresses this with a non-root OCI like Podman.
AND maybe the answer is that I have to enforce a root account for Podman, but I figured I would give a shout out to the community before I threw my laptop out the window.
Thanks in Adv.
G...C
UnKulMunki