docker安裝的mysql修改配置文件方式
一、先看一下容器綁定的配置文件目錄在哪
docker inspect 347
如圖:
mysql容器的配置文件映射在服務(wù)器 /opt/mysql_docker/conf目錄下。
所以想修改容器的配置文件內(nèi)容,只需要修改 /opt/mysql_docker/conf中的配置文件。

二、發(fā)現(xiàn) /opt/mysql_docker/conf
目錄下沒有文件
三、進(jìn)入mysql容器
復(fù)制mysql的配置文件內(nèi)容
docker exec -it 347 /bin/bash cd /etc/mysql/conf.d cat mysqld.cnf
復(fù)制內(nèi)容如下:
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, # as published by the Free Software Foundation. # # This program is also distributed with certain software (including # but not limited to OpenSSL) that is licensed under separate terms, # as designated in a particular file or component or in included license # documentation. The authors of MySQL hereby grant you an additional # permission to link the program and your derivative works with the # separately licensed software that they have included with MySQL. # # 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, version 2.0, 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.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONroot@347e69759ec4:/etc/mysql/conf.d# cat mysqld.cnf
四、在服務(wù)器/opt/mysql_docker/conf 下
新建配置文件mysqld.cnf,內(nèi)容來自第三步復(fù)制內(nèi)容。
五、重啟容器
docker start 347
發(fā)現(xiàn)報(bào)出異常如下:
Error response from daemon: driver failed programming external connectivity on endpoint mysqlserver (c97a49898a84bdfaadaa8510a81f99d3eb7b19fd3eb4451dba7f6d70f9516409): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.18.0.5:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))
Error: failed to start containers: 347
解決方法:
重啟docker,再啟動(dòng)mysql容器。
service docker restart
六、總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
樹莓派3B+安裝64位ubuntu系統(tǒng)和docker工具的操作步驟詳解
這篇文章主要介紹了樹莓派3B+安裝64位ubuntu系統(tǒng)和docker工具,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-09-09
基于 Docker 搭建 Anythingllm的詳細(xì)過程
本文詳細(xì)介紹了如何在本地Windows 11企業(yè)版上使用Docker搭建和部署Anythingllm,包括Ollama和Docker的安裝步驟,以及配置和使用Anythinllm的具體方法,感興趣的朋友一起看看吧2025-03-03
使用docker構(gòu)建一個(gè)redis鏡像的方法詳解
Redis是一個(gè)開源的使用ANSI C語言編寫、支持網(wǎng)絡(luò)、可基于內(nèi)存亦可持久化的日志型、Key-Value型NoSQL數(shù)據(jù)庫,本文介紹了docker創(chuàng)建redis鏡像的方法,分享給大家,需要的朋友可以參考下2024-06-06
使用Docker部署可視化面板監(jiān)控Nginx的流程步驟
使用 Docker 部署 Prometheus、Grafana 和 Nginx Exporter,確保它們能夠正確通信并監(jiān)控你的 Nginx 服務(wù),本文給大家詳細(xì)介紹了使用Docker部署可視化面板監(jiān)控Nginx的流程步驟,需要的朋友可以參考下2025-05-05
使用Docker compose編排Laravel應(yīng)用的方法
本篇文章主要介紹了使用Docker compose編排Laravel應(yīng)用的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-07-07

