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?

2 Answers 2


The way Docker containers work, is that they're isolated by default, unless you set them up otherwise.

To answer your question you can open the ports that you want, and also link containers via these ports, so they only communicate via the port you specify.

When specifying in a Dockerfile, this command is called 'EXPOSE': http://docs.docker.io/reference/builder/#expose

EXPOSE  41000

When starting a container, you can pass the port you want to expose as well, right when it starts up (overrides what may be specified in the original Dockerfile):

sudo docker run -p 41000:41000 -d <your username>/<your image name>

-p, --publish=[] Publish a container's port to the host format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort (use 'docker port' to see the actual mapping)

See Linking as well, http://docs.docker.io/use/working_with_links_names/#working-with-links-names

Further reading regarding Wordpress and Docker:


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.

  • I'm aware of that. I'm just wondering how I connect one container to another container. For example, if my MySQL container exposes port 41000 to the host operating system, how does the PHP container connect to MySQL at this port? Do all host ports become available to containers? I would assume that host ports would by default not be available to containers in the interest of security. Mar 30, 2014 at 19:31
  • Updated. I guess the default will be pretty much open, unless the guest system employs its own security features. Mar 30, 2014 at 21:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .