修改已经创建的docker容器的端口映射

获取容器id:

docker container list –all
docker inspect <容器id>   |  grep Id
docker stop <容器id>

修改docker配置文件:

vim /var/lib/docker/containers/[容器hash]/hostconfig.json
修改PortBindings参数配置,宿主机8001端口映射容器80端口示例:
 
“PortBindings”:{80/tcp”:[{“HostIp”:””,”HostPort”:”8001}]},”
 
systemctl restart docker
docker start <容器id>
  • virtualization/docker/修改端口映射.txt
  • 最后更改: 2020/08/05 03:45
  • (外部编辑)