docker安装mysql并且外挂文件目录-飞外

# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; version 2 of the License.# This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA# The MySQL Server configuration file.# For explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html[mysqld]pid-file = /var/run/mysqld/mysqld.pidsocket = /var/run/mysqld/mysqld.sockdatadir = /var/lib/mysqlsecure-file-priv= NULL# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Custom config should go here!includedir /etc/mysql/conf.d/

5. 创建并且启动docker

docker run  -p 3306:3306  -e MYSQL_ROOT_PASSWORD=test@123  -v /docker/mysql/data:/var/lib/mysql  -v /docker/mysql/log:/logs  -v /docker/mysql/conf/my.cnf:/etc/mysql/my.cnf  --name mysql_1  --restart=always  -d mysql:latest