1、停止容器
docker stop 容器ID
2、停止docker
systemctl stop docker
3、修改文件
? 先进入目录
cd /var/lib/docker/containers/容器ID*
(1)修改hostconfig.json 文件
vi hostconfig.json
找到类似如下字段:
"PortBindings": {
"111/tcp": [
{
"HostIp": "",
"HostPort": "111"
}
],
"222/tcp": [
{
"HostIp": "",
"HostPort": "222"
}
]
}
? 按照json 文件格式添加或修改成需要的端口号即可
(2)修改config.v2.json 文件
? 修改两处:
①、一处为:
"ExposedPorts": {
"111/tcp": {},
"222/tcp": {}
}
②、另一处为:
"Ports": {
"111/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "111"
},
{
"HostIp": "::",
"HostPort": "111"
}
],
"222/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "222"
},
{
"HostIp": "::",
"HostPort": "222"
}
]
}
和修改hostconfig.json 文件类似,符合json 语法格式即可
4、重启docker
systemctl stop docker
5、重启容器
docker start 容器ID
|