【问题标题】:Error instruction COPY on DockerfileDockerfile 上的错误指令 COPY
【发布时间】:2018-07-30 09:48:17
【问题描述】:

我正在使用 Dockerfile 在 docker 上构建 MYSQL 映像。我需要帮助,因为我有这个问题: Authentication plugin 'caching_sha2_password' cannot be loaded

Aman Aggarwal 的解决方案对我有用,但我需要将它写在我的自定义 my.cnf 上,我尝试用它重写 my.cnf 默认值,但是在执行 docker build 时出现错误:

复制失败: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/

这是我的 Dockerfile:

# 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

【问题讨论】:

    标签: mysql database dockerfile mysql-workbench


    【解决方案1】:

    来自Docker documentation

    COPY 指令从<src> 复制新文件或目录,并且 将它们添加到容器的文件系统中,路径为<dest>
    .
    .
    .
    <dest> 是绝对路径,或相对于 WORKDIR 的路径,进入 源将被复制到目标容器中。

    您正在指定目标文件名,而不仅仅是目标目录。另请注意,不需要重新启动 MySQL 服务。该服务在容器启动时启动,而不是在构建时启动,因此您只需要:

    # 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/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-12
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      • 2019-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多