WordPress on Docker

WordPress is a content management system for running blogs or websites. Meanwhile, Docker is a software container platform for building, shipping and running applications and/or utilities. Since there are thousands of Docker images already built, installing an application such as WordPress is fairly easy. In this article, I will show you how to install WordPress, MySQL, PHPMyadmin on the Docker environment.

Install Docker

Docker is agnostic, meaning it really doesn’t matter what platform you use, whether you’re on Windows, Linux or the Mac.

Download Docker Docker. Install.

Create A Project Folder

$ mkdir wordpress
$ cd wordpress

Create a Docker Compose file

The docker file for composing an image is called docker-compose.yml. It’s a YAML file that contains instructions on what to do and apps to use.

$ nano docker-compose.yml

Type in the following configuration in the YAML file. In this example, I’m telling docker to install WordPress, MySQL and PHPMyAdmin and using the following TCP ports, credentials, and volumes.

  image: wordpress
    - wordpress_db:mysql
    - 8080:80
    - ~/Docker/wordpress/html:/var/www/html
  image: mariadb
  image: corbinu/docker-phpmyadmin
    - wordpress_db:mysql
    - 8181:80

Run Docker Compose

$ docker-compose up -d

The installation may take anywhere from 5-10 mins or longer. So, grab a cup of coffee.

Access WordPress

Once installed, open up your browser and access WordPress and PHPMyadmin

WordPress at: http://localhost:8080
PHPMyAdmin at: http://localhost:8181

You can access the WordPress files from your project’s “wordpress/html” directory.


That’s it.

Missing add-apt-repository command

When adding a new repository in Ubuntu, you can go the PPA route by using the add-apt-repository command. If you’re getting a missing add-apt-repository command, it’s probably not installed. You need to install the “software-properties-common” and “python-software-properties” packages from the Terminal. By the way, if you’re curious, PPA means personal package archive. PPAs are repositories hosted on Launchpad which you can use to install or upgrade packages that are not available in the official Ubuntu repositories. Just think of them as extended repositories.

If you’re getting a missing add-apt-repository command, just install the following:

$ sudo apt-get install software-properties-common python-software-properties

Once installed, you can then add other repositories that you want.

Let’s say you want to install Sublime Text 2, a real popular text editor.

You can install Sublime Text 2 via the PPA route using the following.

$ sudo add-apt-repository ppa:webupd8team/sublime-text-2
$ sudo apt-get update
$ sudo apt-get install sublime-text-2

Or install the latest Gimp release:

sudo add-apt-repository ppa:otto-kesselgulasch/gimp
sudo apt-get update
sudo apt-get install gimp

To revert the changes:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:otto-kesselgulasch/gimp

Check Open Ports

If you’re running a Linux server, here’s one way of checking as to which ports are open to the public. You can use netstat for that purpose. Netstat is a command-line network utility tool that displays network connections for tcp, routing tables, and a number of network interfaces. It’s available on Linux, MacOS and Windows.

In Linux and MacOS, type the following via the Terminal.

netstat -lnptu
# -l = only services which are listening on some port
# -n = show port number, don't try to resolve the service name
# -t = tcp ports
# -u = udp ports
# -p = name of the program

If you’re in Windows, open up Powershell and type in:

netstat -no
# or
netstat -o 5

Don’t be surprised as to what your computer is doing.

Optimize Your Videos For The Web

If you have a video that you would like to share with others, how do you optimize it for the web. I’m using a simple open-source program called Handbrake which you can download for free. It’s available from handbrake.fr. Handbrake is available on Windows, Mac and Linux. Based on my experience with working with Handbrake, I was able to shrink my videos to less than 10% of the original size without sacrificing quality.

Here’s a short video of how to optimize your videos for the web using Handbrake.