Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkMode parameter uses container ID instead of name #2657

Closed
ryester19 opened this issue Jan 27, 2019 · 8 comments · Fixed by #3398
Closed

NetworkMode parameter uses container ID instead of name #2657

ryester19 opened this issue Jan 27, 2019 · 8 comments · Fixed by #3398

Comments

@ryester19
Copy link

Bug description

In the Network tab underneath the Advanced Container Settings section of a created container, if you're using the "container" Network, the chosen Container sub-option reverts to "Select a container" when you save and view/edit the container settings again.

Screenshot of Problem

As far as I have seen, this is only a cosmetic issue, and the container is still properly configured to use the network of another container.

An additional issue that this causes is that when editing a container, you receive a "Failure Invalid network mode: invalid container format container:" error when trying to deploy. The error vanishes when you select the proper Container sub-option again.

Expected behavior
The chosen Network Container sub-option sticks between edits

Screenshot of How it Should Look

Steps to reproduce the behavior:

  1. Create container using the "container" network
  2. Deploy
  3. Edit created container
  4. See error

Technical details:

  • Portainer version: 1.20.0
  • Docker version (managed by Portainer): 18.09.1
  • Platform (windows/linux): linux x86_64 Debian GNU/Linux 9 (stretch)
  • Command used to start Portainer (docker run -p 9000:9000 portainer/portainer): docker run -p 9000:9000 portainer/portainer --no-auth
  • Browser: Chrome 72
@ryester19
Copy link
Author

ryester19 commented Feb 14, 2019

I have some more insight on this issue.

When creating/recreating a container in Portainer, the NetworkMode parameter in the container's hostconfig.json file is always saved to use the container ID, instead of the name (e.g. "NetworkMode": "container:543hde09...." instead of "NetworkMode": "container:vpn"). If I manually edit the hostconfig.json file to use the name of the container instead, I can see the expected behavior the next time I attempt to edit the container in Portainer.

This also solves a separate issue I was having where I wasn't able to start/restart a container that used --net=container:vpn if that 'vpn' container was recreated prior. Probably due to the fact that the container ID doesn't exist anymore

So I guess the simple(?) solution to this is to make sure that the NetworkMode parameter always saves using the container name, instead of the ID.

@ryester19 ryester19 changed the title Network Container Sub-Option Not Saving NetworkMode parameter uses container ID instead of name Feb 14, 2019
@ndpete
Copy link

ndpete commented Aug 19, 2019

I'm seeing this same behavior with portainer 1.22
Is there a workaround or should I be doing this a different way?

@musabgultekin
Copy link

Using "container" as network name causes issues. Docker thinks its a network_mode configuration. See: https://docs.docker.com/compose/compose-file/#network_mode . It can be a bug or undocumented restriction on docker, i don't know exactly

@deviantony deviantony assigned ghost Nov 1, 2019
@deviantony deviantony added the priority/low Core team priority label Nov 1, 2019
@deviantony deviantony added this to the next milestone Nov 26, 2019
@ghost ghost moved this from Need triage to Confirmed in Bug triage Nov 28, 2019
@ghost ghost removed this from Confirmed in Bug triage Nov 28, 2019
@ryester19
Copy link
Author

ryester19 commented Dec 4, 2019

Just tested with 1.23.0, and I don't believe the main issue has been fixed yet. I apologize that my issue description only focused on the cosmetic problems.

When editing a container immediately after creating it, the correct network container is selected in the UI by default now. However, containers are still being deployed using the ID of the network container, instead of the name. This still causes issues if the parent network container is ever recreated.

For example:

  1. Create container called 'vpn'
  2. Create container called 'torrent', configured to use the network of the 'vpn' container
  3. Immediately recreate the 'vpn' container. Container ID changes.
  4. Edit the 'torrent' container. Network Container drop-down is blank again
  5. Try and recreate the 'torrent' container. You get a "Failure: no Such Container" error that references the old ID of the 'vpn' container.

@deviantony
Copy link
Member

cc @itsconquest

@ghost
Copy link

ghost commented Dec 6, 2019

Thanks for reporting this @ryester27 I have confirmed this behaviour, are you able to open a separate bug report for this?

@gausie
Copy link

gausie commented May 28, 2022

This bug is still not fixed - recreating a container used for networking will cause all the containers using it to lose access because the id of the recreated container has changed.

@weirlive
Copy link

sooo.. this one ever getting fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants