Are you trying to install WordPress with docker-compose?
This guide will help you.
Docker is a system that provides pre-configured, self-contained applications, frameworks, and software stacks, such as WordPress, Golang, or LAMP. Even entire Linux distributions can be run in Docker. When deployed, these software packages are referred to as containers. Docker also allows you to create your own containers that include any custom software you'd like.
Docker Compose is a complementary system which helps you link together individual Docker containers so they can work together. You can deploy WordPress container and another MySQL container that WordPress will use to store its data.
Docker Compose will facilitate the networking between them.
In this context, we shall look into how to install WordPress with Docker compose.
More information about Docker and Docker Compose ?
Docker is a tool that runs applications using containers. Also, it provides pre-configured, self-contained applications, frameworks, and software stacks, such as WordPress, Golang, or LAMP. Moreover, we can run an entire Linux distribution in Docker.
Docker Compose is a complementary system that will help you in linking individual Docker containers so that they can work together.
Here, we shall deploy a WordPress container and another MySQL container that WordPress will use to store its data.
Then Docker-compose will facilitate the networking between them.
Steps to install WordPress with Docker Compose ?
Here you will learn how to install WordPress.
How to Installing Docker ?
Now we shall install Docker Community Edition (CE) using the official Ubuntu repositories.
1. As a first step, we will make sure to remove any old docker installations of Docker that may be on the system.
sudo apt remove docker docker-engine docker.io
2. Next, we ensure that we have necessary packages to allow the use of Docker’s repository:
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
3. Now, we will add the Docker’s GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4. Then we will verify the fingerprint of the GPG key:
sudo apt-key fingerprint 0EBFCD88
5. After that, we will add the stable Docker repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
6. Then we update the package index and install Docker CE:
sudo apt update
sudo apt install docker-ce
7. Add the limited Linux user account to the docker group:
sudo usermod -aG docker $USER
8. Finally, we check if the installation was successful by running the built-in “Hello World” program:
docker run hello-world
How to Install Docker Compose ?
Here we shall download the latest version of Docker Compose.
Check the releases page and replace 1.25.4 in the command below with the version tagged as Latest release:
sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
Then we set file permissions:
sudo chmod +x /usr/local/bin/docker-compose
How to Set Up WordPress ?
Now its time to setup WordPress.
1. First, we create a new directory in the home folder called my_wordpress and cd into it:
2. Now we create a file named docker-compose.yml in this folder and add the following contents. Set your own passwords for the WORDPRESS_DB_PASSWORD, MYSQL_ROOT_PASSWORD, and MYSQL_PASSWORD environment options. The password entered for WORDPRESS_DB_PASSWORD and MYSQL_PASSWORD should be the same:
3. We start the Docker containers from the my_wordpress directory.
docker-compose up -d
4. It will take a minutes to start up WordPress and MySQL. Then you can visit your Server’s IP address/domain name in your web browser and you should be directed to the WordPress setup form.
5. Complete the WordPress setup.
That's it, we are done with the WordPress Setup.
How to Update WordPress ?
Here is the command that we use to update the WordPress version:
docker-compose pull && docker-compose up -d