The possibility of launching a bunch of replicated and load balanced containers is already a good start, but how about more complex application stacks, made of different interconnected containers?
In this case, you can link containers by calling them by name. As we just saw, the internal Swarm DNS server will guarantee a reliable name resolution mechanism. If you instantiate a service called nginx
, you can just reference it as nginx
and other services will resolve to the nginx
Virtual IP (load balanced), hence accessing the distributed containers.
To demonstrate this with an example, we're now going to deploy the more classical of classics on Swarm: WordPress. You can run WordPress as a container, in fact a ready image is available on the Docker Hub, however it requires an external database (in this case MySQL) to store its data.
So, as a start, we'll create a new dedicated overlay network on Swarm, called WordPress, and run one MySQL container on top...