Difficulty: Beginner
Estimated Time: 10 minutes

Team-based Learning 06 - Group 1

In this scenario, we're going to set up two containers in Docker. The first container will run an image of MySQL, which we'll use to store our data. The second container will run an image of Node.js, where we'll perform API-calls, located in a separate container. The data from the Node.js container will be sent to the database in container #1.

By using Docker we can create containers for different purposes, which in our case will be one for Node.js, as well as a separate container for the database.

The purpose of this demonstration is to show how one can run separate applications in their own containers, and allow these containers to interact with eachother (one-way interaction in this case) In addition, the finished product implements SoundClouds and YouTubes APIs to extract data.

The end

Since the application and database were launched in a scenario on a virtual machine hosted by Katacoda, we've also chosen to host the database and application on a server, using Docker of course. Go to to access the application at any time.

The project is naturally open source, so if you're interested in seeing the source code for the project you can find that here

TBL06: Launching containers in Docker

Step 1 of 3

Step 1 - Containerizing a database

In this step, we'll launch a MySQL database in a container in which the data will be stored. We'll begin with the database since the application is dependent on the database for storage.

With Docker, all containers are based on a Docker image. The first step will be to find the image for MySQL. There are a lot of options on Docker Hub, but we'll stick with the official repository, which can be found here.

One way to look up an image is to run the command docker search <name>. Running the command docker search --limit 5 mysql will display the matching repositories, limited to five results with the --limit x option.

To pull the image to your host, run docker pull mysql.

An image can be run by using the command docker run <options> <image-name>. For example, we can run the mysql image in the background by running docker run -d mysql. By default, a container in Docker is launched in the foreground. The option -d makes sure that the process runs in the background.

Finally, to launch an instance of the MySQL image in a container, execute the command docker run --name tbl06db -e MYSQL_ROOT_PASSWORD=tbl06pw -e MYSQL_DATABASE=tbl06 -p 3306:3306 -d mysql

The command option --name gives the container a unique name; tbl06db .

In addition, we set the root password to "tbl06pw", and create and use a database called "tbl06". The option -p exposes the port 3306, which lets the application interact with the database (port 3306 is default for MySQL) Finally, the option -d runs the process in the background.