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.json
file, found athome/docker/containers/[container ID]/config.v2.json
-
Within the
ExposedPorts
section, 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
Ports
section, either edit the existing ports andHostPort
to 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.json
file, found athome/docker/containers/[container ID]/hostconfig.json
. -
Within the
PortBindings
section, either edit the existing ports andHostPort
to 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: