Bobcares

How to install WordPress with Docker Compose

by | Oct 1, 2020

Wondering how to install WordPress with docker-compose? Here’s how we do it.

Here at Bobcares, we have seen several such Docker related queries as part of our Docker Hosting Support for Docker users, web hosts, and online service providers.

Today we’ll take a look at how to install WordPress with Docker compose.

 

What is 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.

In this article, 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.

 

How to install WordPress with Docker Compose

Now let’s take a look at how our Support Engineers install WordPress.

 

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

 

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

 

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:

mkdir ~/my_wordpress/
cd ~/my_wordpress/

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.

version: '3.3'

services:
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wordpress_files:/var/www/html
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: my_wordpress_db_password

db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: my_db_root_password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: my_wordpress_db_password
volumes:
wordpress_files:
db_data:

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 Linode’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.

Update WordPress

Here is the command that we use to update the WordPress version:

docker-compose down
docker-compose pull && docker-compose up -d

[Need any further assistance with Docker related queries? – We’re available 24*7]

 

Conclusion

In today’s writeup, we saw how our Support Engineers installed WordPress with docker compose.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF