Author: Junhao Shen email: [email protected]
- OS:MacOS/Linux
- reference: https://apptainer.org/docs/user/latest/quick_start.html
https://ponyland.science.ru.nl/ponyland/development_tips/mysql_with_apptainer/
...
echo "SET PASSWORD FOR 'root'@'localhost' = '<root_password>';" > .mysqlrootpw
Repalce root_password with your password
apptainer pull --name mysql.simg docker://mysql
run pwd
to get the current directory, and replace ${PWD}
with the output of pwd
or PWD= the output of pwd
apptainer instance start --bind ${PWD} --bind ${PWD}/mysql/var/lib/mysql/:/var/lib/mysql --bind ${PWD}/mysql/run/mysqld:/run/mysqld ./mysql.simg mysql
--bind
makes sure that some directories in the current directory are also available in the container.
apptainer exec instance://mysql mysqld --initialize --init-file=${PWD}/.mysqlrootpw
apptainer exec instance://mysql mysqld --init-file=${PWD}/.mysqlrootpw
check if the container is running on port 3306: lsof -i:3306
apptainer shell instance://mysql mysql -S mysql/run/mysqld/mysqld.sock -u root -p
Enter the password you set in step 2.