$ docker pull mysql:5.7.41
$ docker run -d --name=5.7.41 -e MYSQL_ROOT_PASSWORD=password mysql:5.7.41
4e3c26f116230bbe81ff3338c309292c4da764d773e2337ec916c64a7e690f6b
.2
で起動したコンテナにログイン$ docker exec -it 4e3c26f /bin/bash
bash-4.2#
$ mysql -u root -p
# パスワードはpassword
初期状態では設定ファイルmy.cnf
は存在しない。
bash-4.2# ls -al /etc/mysql/
total 16
drwxr-xr-x 4 root root 4096 Jan 17 21:08 .
drwxr-xr-x 1 root root 4096 Jan 25 04:35 ..
drwxr-xr-x 2 root root 4096 Jan 17 21:08 conf.d
drwxr-xr-x 2 root root 4096 Jan 17 21:08 mysql.conf.d
ホストのカレンドディレクトリにmy.cnf
が存在すると仮定する。my.cnf
はコンテナの/etc/mysql/
か/etc/mysql/conf.d
か/etc/mysql/mysql.conf.d
に配置する。
$ docker run -d --name=5.7.41 -v $(pwd):/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=password mysql:5.7.41
Using a custom MySQL configuration file The default configuration for MySQL can be found in /etc/mysql/my.cnf, which may !includedir additional directories such as /etc/mysql/conf.d or /etc/mysql/mysql.conf.d. Please inspect the relevant files and directories within the mysql image itself for more details.
If /my/custom/config-file.cnf is the path and name of your custom configuration file, you can start your mysql container like this (note that only the directory path of the custom config file is used in this command):
ref. https://hub.docker.com/_/mysql
$ cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="7.9"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Oracle Linux Server 7.9"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:9:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.9
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.9
$ yum update
$ yum install vim
$ yum install less