Overlay network with standalone containers, container restart when managers are unavailable

Hi!

We have some standalone containers (separate edge computers) utilizing the overlay network. These machines are connected with 4G connections, and will sometimes be without a internet connection.

Our issue arises when the edge machines reboots, as the containers will not start when the attachable overlay network is not available. (we need these containers to buffer data until the connection is valid again)

So I guess my question is this: Is there any way to force a start of standalone containers even though the overlay networks is not available?

Thank you for reading my post!

I don’t think thats possible but you could have a network-manager container, and remove the --network argument from your container. Your network-manager container will restart on boot and will constantly try to connect your container to your overlay network. If the network isn’t available the operation will fail and your network-manager can wait x seconds before retrying. If the overlay network is available again the network-manager will successfully connect your container to the overlay network and your container can do its work.

1 Like

This is a great tip, and might be my solution!

I allready have a script (close to finished) that can be run in the host OS, but it would be awesome to modifiy it into a separate network-manager container.

Can this be done with a normal alpine container, with privileged access? Do you have any tips for how the simplest network-manager container can be built/obtained, or how to run docker host commands inside a container?

Here is my startup script for my host OS(not finished/tested)

docker network disconnect myNetwork myContainer
docker start myContainer

while [ ! "$(docker network ls -f name=myNetwork )" ] ;
do
    echo 'Docker network myNetwork is not present, execute standalone container onboadring procedure';
    docker network connect myNetwork myContainer
done
    echo 'Docker network myNetwork is OK, noting to do but maybe log it to some logfile'

You can mount the docker socket into the container and install the CLI in the container or use the docker engine API to do your magic.
(Disclaimer: Not tested)

1 Like