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
Post comment 取消回复