Search The Hostwinds Guides Knowledge Base

Install Docker and WordPress On Ubuntu

Share This Article [TheChamp-Sharing]

 

What is Docker? Docker is a containerization platform that performs operating system level virtualization, which lets you run lightweight containers in isolation. The following document will take you through the steps to install Docker and run a WordPress & MySQL container.

Installing Docker

  1. Install docker from from the official repository.

     

    curl -sSL https://get.docker.com/ | sh

     

  2. Use the command below check to verify the version.

     

    docker version
  3. 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
  1. Install Docker Compose, same as earlier and making sure it’s executable.
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
  1. Let’s check the versions of docker-compose and docker-machine.
docker-compose version
docker-machine version

Launching WordPress & MySQL Containers

To run WordPress, you will need to run two separate containers. Besides WordPress container you must also install the database container.

  1. Start by pulling the docker image.
docker image pull mysql

 

  1. Launch MySQL by running the following command:
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 are calling the container mysql by using (–namewordpress). 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.

  1. Verify the container is running as expected by using the following command:
docker container ps

 

Supplemental step: to check the status of your mysql container run the following command.

docker container logs mysql
  1. Now we install the WordPress container image.
docker image pull WordPress
  1. Launch the WordPress container
docker container run -d \

   --name wordpress \

--link mysql:mysql\

   -p 8080:80 \

   -e WORDPRESS_DB_PASSWORD=wordpress \

   wordpress
  1. Verify the wordpress container is running as expected by using the following command:
docker container logs mysql
  1. If you notice that it isn’t on your can start the wordpress container by issuing the following command.
docker container start wordpress