Docker修改已创建容器端口映射

修改已创建容器端口映射。

通过编辑 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"}]}

本文参考:https://stackoverflow.com/questions/19335444/how-do-i-assign-a-port-mapping-to-an-existing-docker-container

posted @ 2019-05-31 01:06  NWGDK  阅读(1310)  评论(0编辑  收藏  举报