Docker - Install MySQL and WordPress Using Docker




Install MySQL Using Docker


MySQL is one of the most common open source databases available today. We are going to go through how to install MySQL using Docker. If you need refreshing on how to install Docker on ubuntu read this. If you need a refresher on why Docker is important, and what some of the possibilities are, read this.

This post is going to assume that you have already installed Docker on Ubuntu. It’s important to note here: I usually prefer using a PaaS service for databases in general such as AWS RDS. But, this is a very good lesson on easily installing MySQL.





Keep us logged in as root

sudo su



Download the MySql image from Docker

docker pull mysql:latest



Next we want to start MySQL

docker run --name test-mysql -e MYSQL_ROOT_PASSWORD='test' -d mysql


This is pretty self explanatory, everything behind the –name tag is the name of the container that will be created. The -d tag allows us to choose which image we want to run.
Once the you get the MySQL container running, you can double check the status and container ID
 docker ps -l 

Installing MySQL into a container gives you amazing flexibility in future tasks. It’s very easy to migrate to other machines, or scale horizontally.




Install WordPress Using Docker


Ryan Ryke

This post will show you how to install WordPress using Docker. We will also link our WordPress container to the MySQL container that we created in the previous post. This will give us the capabilities to scale each group of containers separately. Meaning we can scale the database, as well as the WordPress front end separately giving us much more flexibility.
In order to follow along in this post please review my post showing how to install MySQL using Docker

Install WordPress using Docker


First things first, lets login as root to save us from having to type sudo.
 sudo su

Once that is out of the way, we are going to download the WordPress image
docker pull wordpress:latest

This next step is very simple, but can require a little bit of research if you want to get very customized.

docker run --name test-wordpress --link test-mysql:mysql -p 80:80 -d wordpress

The –name option is going to name our container. The –link option is going to tell this container to link with the container we created previously. The -p option is going to map the internal port with the external port (-p host port:container port). So in my case, I used 80:80 to tell it that I want to map my host port 80 to the internal container port 80.

The options for this particular image can be located here 
If you haven’t previously installed MySQL, I recommend using the Tutum Image

Comentarios

Publicar un comentario