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

[BUG]: Container name in network mode replaced by digest #254

Closed
srosorcxisto opened this issue May 16, 2024 · 3 comments
Closed

[BUG]: Container name in network mode replaced by digest #254

srosorcxisto opened this issue May 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@srosorcxisto
Copy link

srosorcxisto commented May 16, 2024

What happened?

When restarting a system, any ServApp that uses the container network mode fails to start until the compose file is edited. This is due to Cosmos rewriting the compose file and squashing the network name and replacing it with an ephemeral idand adding an unsupported hostmame.

What should have happened?

The container should restart using the same network configuration that was originally set.

How to reproduce the bug?

  1. Start a container that references another contain for its network mode (such as "container:gluetun")
  2. observe that cosmos rewrote the network line to use the id instead of the container name and cosmos has added an illegal host name.
  3. Reboot the system
  4. The container fails to start because it can't find the container id

Relevant log output

Relevant log entry when attempting to start a container after system restart:

[ERROR] Docker - Cannot get container IP : Error response from daemon: No such container: 4aaf43c592ec0ba469de5f569b39d3db4001786a736b92711f5a705eab57ebae

Other details

I was not sure if this should be reported as a feature request or bug. Since it ultimately does result in breakage, I chose to initially submit as a bug.
When loading an external docker compose file, cosmos replaces the container name with the id of a container when setting the network type.

As an example, if I have a container I want to route through gluetun, I would add this to the docker config:

network_mode: "container:gluetun"

This works as expected, however cosmos rewrites the docker-compose file to point to the container using the id like this:

"network_mode": "container:4aaf43c592ec0ba469de5f569b39d3db4001786a736b92711f5a705eab57ebae"

This is great, except that when the system is restarted for any reason, the container id is changed and any container that was pointing to the gluetun container will fail to boot until the dock-compose file is changed back to network_mode:

"container:gluetun".

Similarly, cosmos automatically adds a hostname to the compose file which has to be removed every time the container is pulled since hostnames are not compatible with container network modes. I have not found a workaround for this:

  "hostname": "4aaf43c592ec",

System details

  • OS: Debian stable
  • Browser Firefox 126
  • Version 0.15.7
@srosorcxisto srosorcxisto added the bug Something isn't working label May 16, 2024
@azukaar
Copy link
Owner

azukaar commented May 20, 2024

This is actually Docker not with Cosmos doing that, unfortunately you will have the same issues with any system (like Portainer)
There is however a "solution" (or a hack) in COsmos to prevent this: set the label cosmos-force-network-mode to container:gluetun and it should revert Docker's change everytime it screws up your Container

@azukaar azukaar closed this as completed May 20, 2024
@srosorcxisto
Copy link
Author

Thanks! That worked like a charm!

Is there a place to contribute a pull request to the documentation? I did not see it as part of the repository.
I am happy to take a crack at expanding the Networking documentation to include this if you would like. It is a very handy feature, and I am sure that it probably comes up a lot, especially for gluetun users since that is not part of the ServApps repository.

For that matter, is there a specific reason Gluetun is not in the repository, or just that no one has submitted a pull request before? I am happy to submit a pull request for that as well if its the latter.

@azukaar
Copy link
Owner

azukaar commented Jun 11, 2024

I'd love to get some help expanding the notification. Back then I started opening a repo and all that but I did not finish making it actually publish the doc on change. If you ping me on Discord I will keep your contact aside and will let you know once you can start contributing
Thanks for the help 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants