我正在用dockerfile在docker上构建mysql映像。我需要帮助,因为我有这个问题:身份验证插件'caching\u sha2\u password'无法加载
aman aggarwal的解决方案适合我,但我需要在自定义的my.cnf上编写它,我尝试用它重写my.cnf默认值,但在执行docker构建时出现错误:
复制失败:stat/var/lib/docker/tmp/docker-builder204357196/my.cnf:没有这样的文件或目录
这是我的自定义my.cnf:
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# 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]
default_authentication_plugin = mysql_native_password
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Custom config should go here
!includedir /etc/mysql/conf.d/
这是我的文件:
# Indicates that the mysql image will be used as the base image.
FROM mysql
# Try copy my.cnf on this path /etc/mysql/
COPY my.cnf /etc/mysql/my.cnf
# Try only to restart mysql (not container)
RUN service mysql restart
我的文件夹结构:
proyectos(folder)
->build_docker
->Dockerfile
->my.cnf
1条答案
按热度按时间ars1skjm1#
从docker文档:
copy指令从中复制新文件或目录
<src>
并将它们添加到路径处容器的文件系统中<dest>
..
.
这个
<dest>
是绝对路径,或相对于workdir的路径,源将被复制到目标容器中。您指定的是目标文件名,而不仅仅是目标目录。还要注意,重新启动mysql服务是不必要的。服务在容器启动时启动,而不是在构建时启动,因此您只需要: