WordPress is the most popular content management system (CMS) in the world. It’s simple and easy to use, but it can also be extended with thousands of plugins and themes. WordPress is free and open source, so thousands of developers have built products that integrate with it.
In this tutorial, you’ll learn how to deploy a WordPress site on DigitalOcean using Docker Compose. This will give you more flexibility than using a traditional virtual machine virtual private server (VPS).
Setup WordPress With Docker
WordPress is a widely used open-source platform for building websites. It’s easy to install, customize and secure. But sometimes you might want to run your own WordPress instance on your local machine. In this guide, I will show you how to setup a local WordPress with Docker and PHPMyAdmin.
I will be using the following software:
Docker (https://docs.docker.com/install)
Docker Compose (https://docs.docker.com/compose/)
PHPMyAdmin (http://www.phpmyadmin.net/)
The following steps explain how to setup WordPress with Docker.
1. Create a new project directory named wordpress-docker-project:
$ mkdir wordpress-docker-project
2. Initialize the project with the docker compose file:
$ cd wordpress-docker-project && docker-compose up -d –build –no-cache
This command will download the latest version of the official PHP image from Docker Hub and create a MySQL container based on the default MySQL image. It will also pull the official nginx image from Docker Hub and start both containers as well as link them together, so that they can communicate with each other.
3. Check if everything works by visiting http://localhost:8080/ in your browser:
This tutorial will walk you through setting up a WordPress development environment using Docker.
Prerequisites
This tutorial assumes that you already have Docker installed on your computer. If you don’t, please follow the instructions in the official Docker documentation for installing Docker on your platform of choice.
Video Tutorial
If you prefer video tutorials, check out this video:
Docker is a containerization platform that allows you to package your app into an image that can be run on any Linux server. Every Docker container is completely isolated from the host machine and other containers.
WordPress is a popular open source blogging platform. It has been around since 2003 and continues to be one of the most popular content management systems in use today. With the release of Docker for Mac or Windows, you can run a fully functional WordPress blog without having to worry about managing servers or installing any software on your computer.
For this tutorial, we are going to use the latest version of Docker (v1.11). We will also be using Docker Compose which allows us to create multiple containers at once with a single YAML file.
Install Docker and Docker-Compose
The first thing you need to do is install docker and docker-compose on your machine.
If you haven’t already installed Docker and Docker Compose, you can head over to the official docs for instructions on how to do so.
Create a new project directory in your home folder. This is where we’ll store our WordPress files. In this example, I’m using ~/projects/wordpress-docker as the directory name. But feel free to choose whatever name you like!
Open up your terminal and run the following command:
mkdir ~/projects/wordpress-docker && cd ~/projects/wordpress-docker && touch wp-config.php
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Compose works with any application framework, but it provides special integration with WordPress to make working with containers more convenient.
You can use Docker Compose to run WordPress in development, staging or production environments. You can also use it to set up a development environment for any other PHP application that can be managed with Composer.
This article will show you how to use Docker Compose to manage the following parts of a WordPress site:
Database (MySQL)
WordPress core files
WordPress plugins
Nginx web server
Docker Compose WordPress
Docker Compose is a command-line tool that allows us to create and configure multi-container Docker applications. It can also be used to run a single container, which is what we’ll do in this tutorial.
To get started, we’ll need to create our project directory and initialize it as a git repository:
mkdir wordpress-compose && cd wordpress-compose
git init -f
The following guide will walk you through setting up a WordPress site in Docker.
This guide assumes that you already have Docker installed and configured on your computer. If not, please follow the official Docker installation guide.
Docker Compose is used to define and run multi-container applications with Docker. The following configurations will be used in this guide:
The WordPress application running on port 8080 of your host machine. This can be reached by visiting http://localhost:8080/ in a browser. The container will also be accessible at http://localhost/.<br>
The MySQL database instance running on port 3306 of your host machine. You can access this using the username root and password root .<br>
The NGINX web server serving our application from port 80 on our host machine.<br>
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. It gives software developers the ability to package their applications into containers that can run on any Linux server.
Docker Hub WordPress
Docker makes it simple to create lightweight, portable, self-sufficient containers from any application using a variety of technologies such as LAMP (Linux, Apache, MySQL and PHP) or MEAN (MongoDB, ExpressJS, AngularJS).
A container can be compared to a virtual machine but with some significant differences. A virtual machine like VirtualBox or VMware will have its own operating system installed on top of the host operating system. If you have used VirtualBox or VMware before you will know that these virtual machines are very resource hungry and slow down your computer if you don’t have enough resources available. Also when you run a virtual machine it is running in full isolation from your host operating system which means that if something goes wrong inside the virtual machine it doesn’t affect your host operating system at all. On the other hand when running Docker containers they use the same operating system as the host so there are no isolated environments like with virtual machines which makes them much faster than virtual machines!
WordPress is one of the most popular CMSs available today. It
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.