1. make sure you’ve cloned the git repo mentioned earlier in the chapter
2. once in the repo, run:
to build the application.
3. create this Dockerfile (not the one mentioned in the book)
FROM alpine LABEL maintainer="email@example.com" COPY bin/1/amd64/kuard /kuard ENTRYPOINT ["/kuard"]
MAINTAINER is deprecated. Use a LABEL instead: https://github.com/kubernetes-up-and-running/kuard/issues/7
MAINTAINER can take 1 argument,
LABELtakes key/value pairs. E.g.
And the COPY path in the book is incorrect.
docker build -t kuard-amd64:1 .
to build the Dockerfile.
Here we’ve got a repo name of
kuard-amd64 and a tag of
4. Check the repo using
Note: a registry is a collection of repositories, and a repository is a collection of images
Files removed in subsequent layers are not available but still present in the image.
Or a specific one:
docker image ls <repository name>
alpine is 4.41MB.
Let’s create a 1MB file and add / remove it:
dd if=/dev/zero of=1mb.file bs=1024 count=1024
then copy it in:
FROM alpine LABEL MAINTAINER=me COPY 1mb.file /
Now building it (and creating a repo called
alpine_1mb) we can see the image has increased in size by a bit over 1MB (probably due to the overhead of an additional layer).
However, if we now remove this file in a subsequent Dockerfile – e.g. with something like:
FROM alpine_1mb LABEL MAINTAINER=me RUN rm /1mb.file
the image is still the same size.
The solution is to ensure you use an
rm in the same
RUN command as you create/use your big file: https://stackoverflow.com/questions/53998310/docker-remove-intermediate-layer
To run the
kuard app, use:
docker run -d --name kuard --publish 8080:8080 gcr.io/kuar-demo/kuard-amd64:1
docker tag kuard-amd64:1 gcr.io/kuar-demo/kuard-amd64:1
According to https://docs.docker.com/get-started/part2/#tag-the-image
tag command is:
docker tag image username/repository:tag
but what’s the
The answer is that Docker’s docs here:
are incorrect. You don’t need a username or repository. It’s just a label. E.g. see https://docs.docker.com/engine/reference/commandline/tag/
Correct would be:
docker tag image <any label you want>:tag
BUT for the purposes of pushing to a repository that label DOES need to be of a specific format. i.e.
Shame they didn’t explain that in more detail.
And the next line is misleading too.
docker push gcr.io/kuar-demo/kguard-amd64:1
This creates the impression that you’re pushing your image to a website (or registry) hosted at
It’s just the tag you created above. Having said that, I had to simplify the tag (from 2 slashes to 1 slash) to get it to work. E.g.
docker tag kuard-amd64:1 snowcrasheu/kuard-amd64:1
docker push snowcrash/kuar/kuard-amd64:1 The push refers to repository [docker.io/snowcrash/kuar/kuard-amd64] 7b816b232464: Preparing 73046094a9b8: Preparing denied: requested access to the resource is denied
The reason for
denied: requested access to the resource is denied
is that (from https://stackoverflow.com/questions/41984399/denied-requested-access-to-the-resource-is-denied-docker )
You need to include the namespace for Docker Hub to associate it with your account. The namespace is the same as your Docker Hub account name. You need to rename the image to YOUR_DOCKERHUB_NAME/docker-whale.
To login with docker use:
or to use a specific username / password.
docker login -u <username> -p <password>
and push with:
docker push snowcrasheu/kuard-amd64:1
which you should then be able to see on Docker Hub. E.g.
Limit CPU / Memory
docker run -d --name kuard --publish 8080:8080 --memory 200m --memory-swap 1G --cpu-shares 1024 gcr.io/kuar-demo/kuard-amd64:1
How to change a repository name:
Handy copy-and-paste code: https://github.com/rusrushal13/Kubernetes-Up-and-Running/blob/master/Chapter2.md