1 Matching Annotations
  1. Jul 2022
    1. 修改 Docker 运行中 Container 的映射端口。

      (1)停止服务

      停止容器服务

      docker stop <container id>

      停止 docker 服务 (Linux)

      systemctl stop docker

      (2)修改配置

      查看 container 的 id hash 值

      docker inspect <container_name>

      C:\Users\xxj87>docker inspect b61792d860f2 [ { "Id": "b61792d860f24c7ba47f4e270e211736a1a88546375e97380884c577d31dab66", "Created": "2022-07-01T07:46:03.516440885Z", "Path": "/bin/sh",

      配置目录

      [nux]: cd /var/lib/docker/containers/4fd7/

      修改文件 hostconfig.json 中的 PortBindings

      vim hostconfig.json

      "PortBindings":{"2222/tcp":[{"HostIp":"","HostPort":"2222"}],"5000/tcp":[{"HostIp":"","HostPort":"5000"}],"80/tcp":[{"HostIp":"","HostPort":"40001"}],"8070/tcp":[{"HostIp":"","HostPort":"8070"}],"8081/tcp":[{"HostIp":"","HostPort":"8081"}]},

      "80/tcp":[{"HostIp":"","HostPort":"40001"}] 80 容器内部端口 40001 外部映射端口

      修改 config.v2.json 中的 ExposedPorts

      vi config.v2.json "ExposedPorts":{"2222/tcp":{},"5000/tcp":{},"80/tcp":{},"8081/tcp":{},"8070/tcp":{}},

      重启服务

      systemctl start docker

      启动容器

      docker start <container id>

      验证修改

      docker ps -a