Have you ever created a container avec after some testing found out you forgot to do some port forwarding ?
Here is how to fix this without having to recreate the container:
-
Get the container ID:
docker ps -a -
Stop the container:
docker stop [container name] -
Stop the docker:
/etc/init.d/dockerd stop(or for generic linux:systemctl stop docker) -
Edit the container
config.v2.jsonfile, found athome/docker/containers/[container ID]/config.v2.json -
Within the
ExposedPortssection, either edit the existing ports to the port you would like, or add them yourself. For example adding UDP port 1202:
"ExposedPorts":{"1880/tcp":{}},
to
"ExposedPorts":{"1880/tcp":{},"1202/udp":{}},
- Within the
Portssection, either edit the existing ports andHostPortto the port you would like, or add them yourself. For example adding UDP port 1202:
"Ports":{"1880/tcp":[{"HostIp":"0.0.0.0","HostPort":"1880"}]},
to
"Ports":{"1880/tcp":[{"HostIp":"0.0.0.0","HostPort":"1880"}],"1202/udp":[{"HostIp":"0.0.0.0","HostPort":"1202"}]},
-
Save and exit the config file
-
Edit the container
hostconfig.jsonfile, found athome/docker/containers/[container ID]/hostconfig.json. -
Within the
PortBindingssection, either edit the existing ports andHostPortto the port you would like, or add them yourself. For example adding UDP port 1202:
"PortBindings":{"1880/tcp":[{"HostIp":"","HostPort":"1880"}]},
to
"PortBindings":{"1880/tcp":[{"HostIp":"","HostPort":"1880"}],"1202/udp":[{"HostIp":"","HostPort":"1202"}]},
-
Save and exit the config file
-
Reboot the PLC
Original infomation: