When you need to publish a certain port on an already running container, you can do so by changing the internal docker file

First, you need to find the container id

docker inspect <container_id>

If the container is running, stop the container and enter the container directory

cd /var/lib/docker/containers/<container_id>

Add ExposedPorts to config.v2.json

"Config": {
     ....
     "ExposedPorts": {
         "<port_number>/tcp": {},
     },
     ....
},

And PortBindings to hostconfig.json

"PortBindings": {
      "<port_number>/tcp": [
          {
              "HostIp": "",
              "HostPort": "<port_number>"
          }
      ]
  }

Now you can start the container, it has modified the mapped port

Likes(0)

Comment list count 0 Comments

No Comments

WeChat Self-Service

WeChat Consult

TaoBao

support@elephdev.com

发表
评论
Go
Top