> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-container/docker-problem-with-network-changes.md). Agents can also search and read this documentation through its [MCP server](https://docs.cybus.io/~gitbook/mcp).

# Docker Problem with Network Changes

Prevent short connection losses for outside MQTT and HTTP clients when you enable or disable a service that contains containers.

When you enable or disable a service that contains [Cybus::Container](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-container.md) resources, MQTT and HTTP clients outside Connectware can lose their connection for a short time. The connection then comes back without intervention.

It happens because Docker can switch the default gateway of the Connectware ingress proxy when the Docker network configuration of the proxy changes. The problem occurs only when the service ID sorts before the name of the Connectware-internal Docker network.

## Observed Errors

If the default gateway of the ingress proxy changes, every ongoing MQTT or HTTP client connection to Connectware drops for about 10 seconds. Afterwards, the containers inside Connectware are reachable again.

At the same time, the Docker logs of the `container-manager` container show a message with log level WARNING like the following:

```
Ingress container default network changed to anotherService. Was connectware_cybus.
```

## Service-Specific Networks

Connectware runs the containers of each service in a separate Docker network, named after the [service ID](https://docs.cybus.io/2-8-0/data-flows/services/serviceid.md). This network connects the containers of the service and the ingress proxy container of Connectware. The name of the ingress proxy container combines the Docker Compose project name, the service name `connectware`, and the suffix `1`, for example `connectware-connectware-1`.

A further Docker network connects the Connectware-internal containers. Its name combines the Docker Compose project name and `cybus`. In a default installation, it is named `connectware_cybus`.

Each time you enable a service with containers, Connectware creates a new network for it. Connectware connects this network to the service containers and to the common ingress proxy. When you disable the service, Connectware disconnects the network from the ingress proxy and from the service containers.

So the network configuration of the ingress proxy changes each time. This is not a problem as long as the change leaves the default gateway of the ingress proxy as it is.

## Ingress Proxy Default Gateway

Docker chooses the network that sets the default gateway of a container by the lexicographical order of the network names.

Without service-specific networks, the ingress proxy is connected to the Connectware-internal network only, for example `connectware_cybus`. Requests from outside clients, such as REST requests over HTTP and MQTT data connections, reach the Connectware-internal containers through the ingress proxy. The ingress proxy routes each request to the container that answers it.

The problem occurs when a service ID sorts before the name of the Connectware-internal network. For example, the service ID `anotherService` sorts before `connectware_cybus`, because `a` comes before `c`.

When you enable `anotherService`, Docker changes the default gateway of the ingress proxy from the `connectware_cybus` network to the `anotherService` network. Outside clients lose their connection until the routing also tries the other networks, one by one, and reaches the internal containers again.

## Scope Limitation

The problem concerns only a very specific scenario. It does not occur in any of the following cases:

* You do not enable or disable services, and the services keep running.
* The services that you enable or disable contain no Cybus::Container resources.
* All installed services have service IDs that sort after the name of the Connectware-internal network.
* No outside clients are connected to Connectware over MQTT, HTTP, or TCP.

Connections from Connectware to other servers or machines are not affected.

## Workarounds

If the short connection loss affects your clients, use one of the following workarounds to avoid it:

* Rename the Connectware-internal network so that it sorts before every service ID, for example `a_a_connectware_cybus`. To do this, change the Docker Compose project name. By default, Docker Compose takes the project name from the directory that holds the `docker-compose.yml` file and in which you run `docker compose`. Rename this directory, for example from `connectware` to `a_a_connectware`. Alternatively, add the `-p` option to every `docker compose` command, for example `docker compose -p a_a_connectware`.
* Give every service ID a name that sorts after the Connectware-internal network. For example, agree on a convention that every service ID starts with `s_`.

{% hint style="warning" %}
When you rename the Docker Compose project of a running installation, copy the data of its Docker volumes into volumes with the new project name. Otherwise, Connectware starts with empty volumes. Docker has no command to rename a volume.
{% endhint %}

## Further Reading

The following reports describe the problem in the Docker runtime:

* <https://github.com/moby/moby/issues/21741#issuecomment-210090728>
* <https://github.com/moby/libnetwork/issues/1141#issuecomment-215522809>
* <https://gist.github.com/jfellus/cfee9efc1e8e1baf9d15314f16a46eca>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-container/docker-problem-with-network-changes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
