docker配置容器mysql启动参数_修改Docker容器启动配置参
有时候,我们创建容器时忘了添加参数 --restart=always ,当 Docker 重启时,容器未能⾃动启动,
现在要添加该参数怎么办呢,⽅法有⼆:
1、Docker 命令修改
docker container update --restart=always 容器名字
2、直接改配置⽂件
⾸先停⽌容器,不然⽆法修改配置⽂件
配置⽂件路径为:/var/lib/docker/containers/容器ID
在该⽬录下到⼀个⽂件 hostconfig.json ,到该⽂件中关键字 RestartPolicy
修改前配置:"RestartPolicy":{"Name":"no","MaximumRetryCount":0}
修改后配置:"RestartPolicy":{"Name":"always","MaximumRetryCount":0}
最后启动容器。
修改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/de9c6501cdd3
cp hostconfig.json hostconfig.json.bak
cp config.v2.json config.v2.json.bak
修改hostconfig的冒号前的配置路径vi hostconfig.json
"Binds": ["/home/server/mysql/conf/myf:/etc/mysql/myf", "/home/server/mysql/logs:/logs", "/home/server/mysql/data
修改config的Source的配置路径vi config.v2.json
"MountPoints": {
"/etc/mysql/myf": {
"Source": "/home/server/mysql/conf/myf",
"Destination": "/etc/mysql/myf",
"RW": true,
"Name": "",
"Driver": "",
"Relabel": "",
"Propagation": "rprivate",
"Named": false,
"ID": ""
},
"/logs": {
docker重启容器命令
"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)
修改docker默认的存储位置
docker 的所有images及相关信息存储位置为:/var/lib/docker查看默认的docker存储路径docker info |grep 'Docker Root Dir'
WARNING: No swap limit support
Docker Root Dir: /var/lib/docker停⽌所有docker容器sudo docker stop $(docker ps -a | awk '{ print $1}' | tail -n +2)停⽌docker 服务sudo service docker stop
cd /var/lib打包docker⽬录sudo tar -czvf /usr/ docker/
cd /usr/
sudo tar -xzvf 修改docker默认的存储位置sudo vim /etc/docker/daemon.json
{
"graph": "/home/server/docker"
}
启动docker服务sudo service docker start启动所有docker容器sudo docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)查看修改后docker存储路径docker info |grep 'Docker Root Dir'
WARNING: No swap limit support
Docker Root Dir: /usr/docker

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。