portainer: Cannot set property /tcp of undefined while editing container port mapping
Description
Trying to expose ports on an already running container, looks like a javascript error:
Steps to reproduce the issue:
- Deploy a container with no ports mapped
- Click Edit/Duplicate
- Click map additional port
- Enter some value into both fields, 80 for example
- Hit Start Container and an error appears with “cannot set property ‘80/tcp’ of undefined”
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?
Technical details:
- Portainer version: 1.14.3
- Target Docker version (the host/cluster you manage): 17.09.0-ce
- Platform (windows/linux): Ubuntu 16
- Command used to start Portainer:
docker run -p 9000:9000 portainer/portainer
- Browser: Chrome stable
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 52 (23 by maintainers)
Commits related to this issue
- Update createContainerController.js fix issue #1261 — committed to meee1/portainer by meee1 5 years ago
- Update createContainerController.js fix issue #1261 — committed to meee1/portainer by meee1 5 years ago
- feat(nomad): add Nomad environment option [EE-2896] (#1494) * feat(environment): introduce nomad [EE-1866] (#1308) * feat(nomad): support nomad in edge stack EE-2467 (#1179) * init commit for s... — committed to portainer/portainer by cmenginnz 2 years ago
+1 I’m also experiencing this error. I also note that in DUPLICATING an existing container the container did not have ay ports and I attempted to create some.
MY specs
Still able to reproduce.
one last comment for now… If i deploy HAproxy, or ubuntu, or home-assistant, and specify a port at deployment time, then i can quite happily edit the container and add other ports without issue.
Looks like a conflict between the Portainer duplicate/edit function and images with no expose declaration.
At least we know now 😃
I’ve tested this development version and can confirm, that a “duplicate/edit” deploy now works as expected, even if no ports are exposed in the dockerfile and can also confirm, that with 1.23.2 this is not possible.
thx Oliver
OK, further research…
neither the HAProxy container image or the home-assistant image have any “EXPOSE” command as part of their docker file, so they are not declaring which ports to expose.
If i build a new image as: from haproxy expose 80
run the newly built image with no ports exposed, edit the container to add port 80, it succeeds.
This is an issue with the underlying images, not portainer.
We should however, handle the error better.
to recreate
in a.HostConfig.PortBindings.forEach(function© { if no previous exposed ports a.ExposedPorts = undefined so it fails