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:

image

Steps to reproduce the issue:

  1. Deploy a container with no ports mapped
  2. Click Edit/Duplicate
  3. Click map additional port
  4. Enter some value into both fields, 80 for example
  5. 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

Most upvoted comments

+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

Version 18.06.1-ce
API version 1.38
Go version go1.10.3
OS type linux
OS Raspbian GNU/Linux 9 (stretch)
Architecture arm
Kernel version 4.14.34-hypriotos-v7+

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

  1. create a container without any port mappings and let it run
  2. use portainer to edit and add a port mapping eg tcp 80:80
  3. goto redeploy and get this error

in a.HostConfig.PortBindings.forEach(function© { if no previous exposed ports a.ExposedPorts = undefined so it fails image