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
build:
docker build -t $(NAME) .
push:
docker push $(NAME)
debug:
docker run --rm -it $(NAME) /bin/bash
run:
docker run --rm $(NAME)
release: build push

Steps
Docker and Makefiles
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.
You’ll love Katacoda

Guided Path
Knowing what you need to know is the hardest part. Our guided pathways help build your knowledge around real-world scenarios.

Learn By Doing
The best way to learn is by doing. All our tutorials are interactive with pre-configured live environments ready for you to use.

Stay up-to-date
It's a competitive industry. Your skills need to keep up with the latest approaches. Katacoda keeps your skills up-to-date.
You’ll love Katacoda

Guided Path
Knowing what you need to know is the hardest part. Our guided pathways help build your knowledge around real-world scenarios.

Learn By Doing
The best way to learn is by doing. All our tutorials are interactive with pre-configured live environments ready for you to use.

Stay up-to-date
It's a competitive industry. Your skills need to keep up with the latest approaches. Katacoda keeps your skills up-to-date.