Wordpress

This article explains how to use Docker Compose to install WordPress with PHPMyAdmin as an extra for database administration. WordPress runs on a Linux, Apache, MySQL & PHP (LAMP) stack.

For the purpose of this tutorial, we use official images from Docker Hub with MariaDB as the Mysql Engine for this tutorial.

  1. Create a virtual machine (VM) using a docker official Ubuntu OMI. For more information, see Creating VMs.

  2. Allow SSH connection to it and connect to your VM via SSH. For more information, see Accessing a Linux VM.

  3. Create a wordpress directory:

    $ mkdir wordpress && cd wordpress
  4. Create a Docker Compose file in it called docker-compose.yml:

    docker-compose.yml
    wordpress:
      image: wordpress
      links:
        - wordpress_db:mysql
      ports:
        - 80:80
      volumes:
        - ~/wordpress/wp_html:/var/www/html
    
    wordpress_db:
      image: mariadb
      environment:
        MYSQL_ROOT_PASSWORD: 53cur3dP455
      ports:
        - 3306:3306
    
    phpmyadmin:
      image: phpmyadmin/phpmyadmin
      links:
        - wordpress_db:db
      ports:
        - 8080:80
      environment:
        MYSQL_USERNAME: root
        MYSQL_ROOT_PASSWORD: 53cur3dP455
  5. Launch everything:

    $ docker-compose up -d

Docker Compose is not installed by default on the OMI used. To install it, launch these additional commands before:

curl -L "https://github.com/docker/compose/releases/download/1.11.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

or alternatively using PIP:

pip install docker-compose