docker-修改容器挂载目录

停止所有docker容器

sudo docker stop $(docker ps -a | awk '{ print $1}' | tail -n +2)

停止docker服务

sudo service docker stop

修改mysql路径

cd ~
sudo cp -r mysql/ /home/server/

备份容器配置文件

cd /var/lib/docker/containers/8e777f913e99
cp hostconfig.json hostconfig.json.bak
cp config.v2.json config.v2.json.bak

修改hostconfig的冒号前的配置路径

vi hostconfig.json
"Binds": ["/home/server/mysql/conf/my.cnf:/etc/mysql/my.cnf", "/home/server/mysql/logs:/logs", "/home/server/mysql/data:/mysql_data"],

修改config的Source的配置路径

vi config.v2.json
       "MountPoints": {
              "/etc/mysql/my.cnf": {
                     "Source": "/home/server/mysql/conf/my.cnf",
                     "Destination": "/etc/mysql/my.cnf",
                     "RW": true,
                     "Name": "",
                     "Driver": "",
                     "Relabel": "",
                     "Propagation": "rprivate",
                     "Named": false,
                     "ID": ""
              },
              "/logs": {
                     "Source": "/home/server/mysql/logs",
                     "Destination": "/logs",
                     "RW": true,
                     "Name": "",
                     "Driver": "",
                     "Relabel": "",
                     "Propagation": "rprivate",
                     "Named": false,
                     "ID": ""
              },
              "/mysql_data": {
                     "Source": "/home/server/mysql/data",
                     "Destination": "/mysql_data",
                     "RW": true,
                     "Name": "",
                    "Driver": "",
                     "Relabel": "",
                     "Propagation": "rprivate",
                     "Named": false,
                     "ID": ""
              },
              "/var/lib/mysql": {
                     "Source": "",
                     "Destination": "/var/lib/mysql",
                     "RW": true,
                     "Name": "85d91bff7012b57606af819480ce267449084e81ab386737c80ace9fe75f6621",
                     "Driver": "local",
                     "Relabel": "",
                     "Propagation": "",
                     "Named": false,
                     "ID": "897cd0152dd152166cb2715044ca4a3915a1b66280e0eb096eb74c2d737d7f77"
              }
       },

启动docker服务

sudo service docker start

启动所有docker容器

sudo docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)
上一篇:[2020年第十一届蓝桥杯JavaB组(七月场)真题解析


下一篇:idea中Tomcat的日志文件