修改已創建容器端口映射。
通過編輯 hostconfig.json
文件來修改 Docker 容器的端口映射
該文件地址:/var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
其中 hash_of_the_container
是你對應容器的 hash 值,需要完整的 hash 值
查看完整的 hash 值:docker inspect -f {{.ID}} containers_name
接着找到如下節點進行修改:
"PortBindings":{}
// 格式如下
"PortBindings":{"8888/tcp":[{"HostIp":"","HostPort":"8888"}]}