Hostwinds Tutorials
Search results for:
Table of Contents
Tags: WordPress, Ubuntu, Docker
What is Docker? Docker is a containerization platform that performs operating-system-level virtualization, letting you run lightweight containers in isolation. The following document will take you through installing Docker and running a WordPress & MySQL container.
Install docker from the official repository.
curl -SSL https://get.docker.com/ | sh
Use the command below check to verify the version.
docker version
Now install Docker Machine by grabbing from it's github repo and making it executable.
curl -L https://github.com/docker/machine/releases/download/v0.14.0/docker-machine-uname -s\-`uname -m` >/tmp/docker-machine
chmod +x /tmp/docker-machine
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
curl -L https://github.com/docker/compose/releases/download/1.21.0-rc1/docker-compose-uname -s\-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /tmp/docker-compose
sudo cp /tmp/docker-compose /usr/local/bin/docker-compose
docker-compose version
docker-machine version
To run WordPress, you will need to run two separate containers. Besides the WordPress container, you must also install the database container.
docker image pull MySQL
docker container run -d \
--name MySQL \
-e MYSQL_ROOT_PASSWORD=wordpress \
-e MYSQL_DATABASE=wordpress \
MySQL
The command we just ran launches the MySQL in the background; we call the container MySQL by using (–name WordPress). The following two environment variables (using -e) to set the MySQL root password to WordPress (-e MYSQL_ ROOT_PASSWORD=wordpress) and created a database called WordPress (-e MYSQL_ DATABASE=wordpress).
For the sake of security, it is highly recommended to use a more complex password during your own setup.
Once you've launched the MySQL container, you should have received a container ID.
docker container ps
Supplemental step: to check the status of your MySQL container, run the following command.
docker container logs MySQL
docker image pull WordPress
docker container run -d \
--name WordPress \
--link MySQL:mysql\
-p 8080:80 \
-e WORDPRESS_DB_PASSWORD=wordpress \
WordPress
docker container logs MySQL
docker container start WordPress
Written by Hostwinds Team / April 10, 2018