Linking Docker containers

containerdockernetworking

I have to migrate my WordPress installation to my own server in order to get SSL working properly. It was originally on GoDaddy shared hosting, which doesn't allow for external SSL cert installation.

Being slightly paranoid and informed about security, I'd like to run the services inside of Docker containers to limit damage in a worst-case scenario.

What I'm not sure of is how to connect Docker containers. For example, I have a Docker container responsible for running MySQL/MariaDB and I don't know how I could share that service with another Docker container running FastCGI which is hosting and executing my WordPress PHP code.

My web server (NGINX) which is currently running outside of a Docker container won't have any problems proxying things along to an exposed port on a Docker container, but how will the FastCGI server (ie: PHP) be able to reach the MySQL container?

Is there a guide which details how to pair up multiple independent services like this in Docker?

Best Answer

Actually Docker doesn't do any virtualization, it's just a tool that handles images and uses LXC container virtualization to run them. I guess you're actually looking for LXC and its capabilities, here. LXC can do virtual networking and MySQL can be accessed over the network. The only thing you need is to connect the building blocks together ;).

In a typical setup, each host has its own IP address and set of open ports and each host can access other host's TCP/IP services over the virtual network. Security is handled by the Linux kernel. One way to handle security is the good old iptables based firewall. But there may be other ways based on selinux labeling.

Related Question