Difficulty: beginner
Estimated Time: 15-20 minutes

Typically containers will not run alone, they will run with other containers to interact with and utilize each other services. Throught this lab we will run containers with different applications and connect them together in order to make use of a container eco-system.

Throught the lab you will:

  • Create a MySQL database container
  • Create a Wordpress container and link it to the database
  • Install wordpress
  • Run a redis container
  • Build a Python application image
  • Link Python application with redis container

Now that you experimented with deploying containerized applications and linking services together, let's learn how to run them using an automated way.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Deploying Containers

Step 1 of 2

Step 1 - Deploy Wordpress

We will start this lab with building a Wordpress website. WordPress is a free and open-source content management system based on PHP and MySQL.

Task

Create MySQL Container

Start off by creating a new MySQL database container:

docker container run -d --name wordpress-database --env MYSQL_ROOT_PASSWORD=qwe123edc mysql

Wait about 1 minute until the database is fully initialized then create a new auxiliary container. This container will be linked to the database container using the option --link. --link option create a link from one container to another container using names. This types of containers is often called side-car container because it's doing a side job for the main container.

docker container run -it --rm --link wordpress-database:wordpress-database --name blaa mysql mysql -u root -p -h wordpress-database

The above command will result in creating a new container and opening the MySQL CLI in your terminal.

Configure Database

We need to create a new database for Wordpress, first create the database with;

create database wordpress;

Then create the user which will be used by the Wordpress server to connect to the database;

create user 'wordpress'@'%' identified by 'qwe123edc';

And grant the new user full access on the wordpress database;

grant all privileges on wordpress.* to 'wordpress'@'%';

Finally exit from the side-car container;


### Create Wordpress Container

Now start a new Wordpress container and link it to the main database container;

```docker container run -d --link wordpress-database:wordpress-database --name wordpress --publish 8000:80 wordpress

Install Wordpress

Navigate to http://[[HOST_SUBDOMAIN]]-8000-[[KATACODA_HOST]].environments.katacoda.com/ which will show you the installer of Wordpress.

  • First choose installation language

    wp-01

  • Confirm information collection

    wp-02

  • Configure database parameters

    wp-03

  • Run the installer

    wp-04

  • Fill in the admin information

    wp-05

  • Log in

    wp-06

Now you can access your new Wordpress installation over URL http://[[HOST_SUBDOMAIN]]-8000-[[KATACODA_HOST]].environments.katacoda.com/