1. 查看需要修改的容器,记住container id
docker ps -a
2. 停止容器
docker stop xxx
3. 修改容器的端口映射配置文件
cd /var/lib/docker/containers
根据容器id查看对应目录,进去该目录(注:此文件夹内的id为很长的字符,只需要看前面docker ps -a显示出来的container_id前面的值对应即可)
编辑json文件:
vi config.v2.json
vi config.v2.json
"Config": {
....
"ExposedPorts": {
"80/tcp": {},
"8888/tcp": {}
},
....
},
"NetworkSettings": {
....
"Ports": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
],
vi hostconfig.json
vi hostconfig.json
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
],
"8888/tcp": [
{
"HostIp": "",
"HostPort": "8888"
}
]
}
4.重启docker服务
service docker restart
5.启动容器
docker start xxx