Using and Abusing Container Metadata
Using and Abusing Container Metadata
Using and Abusing Container Metadata
container metadata
Liz Rice
@lizrice | @microscaling
speakerdeck.com/lizrice/using-and-abusing
-container-metadata
Agenda
● Container images and layers
● Container metadata and labels
● Metadata inheritance
● Metadata automation
Frisbee whizzing
Brian Bilston
through the air
above our heads
over the sand
into the water
onto the waves
out to sea.
App A App B
bins / libs bins / libs
Host OS
server
docker build
Dockerfile image
Let’s make one
Create a new directory
Hello TIAD
Create a file called Dockerfile
FROM alpine:latest
MAINTAINER <your@email.address>
COPY greeting greeting
CMD echo `cat greeting`
Reverse
quotes
You’ll need a Docker Hub namespace
Run it
$ docker login
Look at the image information
MAINTAINER Metadata
CMD Metadata
2. Container metadata
- Tagging
- Labels
Tagging
Distinguish between different versions of the same
image
Edit the greeting file
Run it
$ curl -X POST
https://hooks.microbadger.com/<your webhook>
Look at it on Docker Hub (hub.docker.com) and
MicroBadger
usage
Image
contact
vendor
Alarm system
automatically
connected to git ref
Reproduce contact
problem with
precise usage
codebase Image
contact
Filter
deployed
images from
vendor
vendor
label-schema.org
Standard semantics for container labels
Add labels in your Dockerfile
FROM alpine:latest
MAINTAINER <your@email.address>
COPY greeting greeting
CMD echo `cat greeting`
LABEL org.label-schema.name=“TIAD test” \
org.label-schema.description=“Whatever
you like”
Build a new version of the container with another tag
$ curl -X POST
https://hooks.microbadger.com/<your webhook>
3. Child images & inheritance
Some metadata gets handed down, and some doesn’t
Create a Dockerfile for a child image - call it
Dockerfile.child
FROM <namespace>/tiad:labels
CMD echo yo peeps
LABEL org.label-schema.description =
“Overwrites the old description”
Build the child image
Push it
$ git init .
Add to Dockerfile:
ARG VCS_REF
LABEL org.label-schema.vcs-ref=$VCS_REF
Add substitution params to Dockerfile:
ARG VCS_REF
LABEL org.label-schema.vcs-ref=$VCS_REF
docker_build:
docker build \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +“%Y-%m-$dT%H:%M:%SZ”` .
What not to do!
● Apply ‘latest’ to an old image
● Use someone else’s email as the maintainer
● Don’t look at labels before you build from an image
MicroBadger.com
label-schema.org
@lizrice | @microscaling
Image: Peter Trimming