Welcome!

WordPress

Difficulty:intermediate

Estimated Time:45-75 minutes

WordPress Lab

Now that we have good experience deploying applications as Docker containers, let's try something harder. For this lab, we will deploy WordPress. Specifically, you will need to create two docker container run commands. The first one will deploy MySQL, the second one will deploy WordPress.

We strongly recommend that you build these commands on your local system, in case you lose them on the web host.

Steps

WordPress

Step1 of 2

Create the Database

Configure MySQL

The first thing that you'll do is configure MySQL, which is the persistent store for your blog. Remember, you are only creating a docker container run command to launch this. You do not need to create a Dockerfile.

Your run command should provide the following configuration:

name: db

image: mysql:5.7

volumes: db-data:/var/lib/mysql

network: wordpress-net

environment variables:

MYSQL_ROOT_PASSWORD=wordpress

MYSQL_DATABASE=wordpress

MYSQL_USER=wordpress

MYSQL_PASSWORD=wordpress

Note that you will need to create the network and volume before you execute your docker container run command.

Once you run the database, perform docker container logs db to verify it is up.

Create the Frontend

Configure WordPress

Now that you have MySQL running successfully, its time to launch WordPress. Here is the configuration you need:

name: wordpress

image: wordpress:latest

volumes: wordpress-data:/var/www/html

network: wordpress-net

ports: 8001:80

environment variables:

WORDPRESS_DB_HOST=db:3306

WORDPRESS_DB_PASSWORD=wordpress

Once you run WordPress, view it in your web browser using port 8001. If it isn't working, check the logs (docker container logs wordpress). You may need to restart your MySQL instance if something is not configured correctly.

Help

Katacoda offerings an Interactive Learning Environment for Developers. This course uses a command line and a pre-configured sandboxed environment for you to use. Below are useful commands when working with the environment.

cd <directory>

Change directory

ls

List directory

echo 'contents' > <file>

Write contents to a file

cat <file>

Output contents of file

Vim

In the case of certain exercises you will be required to edit files or text. The best approach is with Vim. Vim has two different modes, one for entering commands (Command Mode) and the other for entering text (Insert Mode). You need to switch between these two modes based on what you want to do. The basic commands are: