Install Docker and WordPress On Ubuntu

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.

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

  1. Now install Docker Machine by grabbing from it’s github repo and making it executable.

 

 

 

 

 

 

 

  1. Install Docker Compose, same as earlier and making sure it’s executable.

 

 

 

 

 

 

 

  1. Let’s check the versions of docker-compose and docker-machine.
 

 

 

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.
 

  1. Launch MySQL by running the following command:
 

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:
 

 

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

 

 

  1. Now we install the WordPress container image.

 

 

 

  1. Launch the WordPress container

 

 

 

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

 

 

 

  1. If you notice that it isn’t on your can start the wordpress container by issuing the following command.

 

 


Share:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.