Difficulty: Beginner
Estimated Time: 10 minutes

In this scenario you will learn how to use Make for managing docker image creation.

Like source code, Docker images are required to be built, tested and deployed. While Docker doesn't have a build framework, you can take advantage of Make to automate the build process across different environments.

Makefiles are text files that provide a simple way to organise code compilation, or in this case Docker image compilation, into named targets. They are used by the make utility in order to execute the required commands to complete an action, such as build a docker images. These Makefiles can contain multiple different targets allowing for a centralised place to store the commands required to build, test, debug and push docker images.

In this scenario we'll explore how to create a Makefile that builds a Docker image.

This was created based on http://blog.benhall.me.uk

As demonstrated in this scenario, Makefiles make it really easy to manage the creation of Docker images. By having a single file you can organise the required commands for creating, debugging and releasing in a single and consistent approach.

NAME = benhall/docker-make-demo
  default: build
      docker build -t $(NAME) .
      docker push $(NAME)
      docker run --rm -it $(NAME) /bin/bash
      docker run --rm $(NAME)
  release: build push

Docker and Makefiles

Step 1 of 5

Step 1 - Dockerfile

This scenario has a Dockerfile which defines a Docker container to output the current date.

The command docker build -t benhall/docker-make-example . will create a Docker image is a friendly tag benhall/docker-make-example which we can use when starting a container based on the image.

In the next step we'll demostrate how to use this command inside a Makefile.

This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]