Docker's native CNM (Container Network Model) provides a out-of-the-box solution to support this use-case. Pls refer to https://github.com/docker/libnetwork/blob/master/docs/design... for more info on Docker CNM. This eliminates the need for any custom scripts to achieve the swappable use-case that you have in mind.
Service (aka endpoint) owns the networking configs (such as ip-address, mac-address, etc...) and the container that backs the service can be swapped while retaining the same networking and service configs. Hence swapping a container between older to newer version of app server is just a matter of detaching a service from the older container and attaching the same service back to the newer container. Also, Please note that a container can belong to multiple networks and each container can publish different services in different network.
We can add more detailed documentation for this specific use-case. Please join us in https://github.com/docker/libnetwork and IRC@freenode #docker-network channel to discuss this in more detail.
The CNM is realized using the newly introduced Experimental Networking solutions which includes : Network & Service UI, Pluggable Service-Discovery and Native Multi-Host cross-container connectivity. More information on trying out these experimental feature : https://github.com/docker/docker/blob/master/experimental/ne... https://github.com/docker/docker/blob/master/experimental/RE...
Service (aka endpoint) owns the networking configs (such as ip-address, mac-address, etc...) and the container that backs the service can be swapped while retaining the same networking and service configs. Hence swapping a container between older to newer version of app server is just a matter of detaching a service from the older container and attaching the same service back to the newer container. Also, Please note that a container can belong to multiple networks and each container can publish different services in different network.
With these simple and composable CNM design, your use-case can be mapped to the CNM model. A quick diagram explaining the concept : https://docs.google.com/drawings/d/1LvD94UwfinQelpEqT9BaRYmi...
We can add more detailed documentation for this specific use-case. Please join us in https://github.com/docker/libnetwork and IRC@freenode #docker-network channel to discuss this in more detail.