Image management

Image management

Images are served from Docker Hub

Images are named [user/]name:tag

docker pull ubuntu
docker pull ubuntu:16.04
docker rmi ubuntu

Different distributions

docker pull centos
docker run -it centos

Look and feel of that distribution with host kernel

Custom images

Custom behaviour

Based on existing image

Adds tools and functionality

Simple but sufficient scripting language

FROM ubuntu:xenial
RUN apt update && apt -y install nginx

Build image from Dockerfile:

docker build --tag myimage .


Specify first process to run

FROM openjdk:11-jre
CMD java -version

Use variables

FROM ubuntu
RUN curl -Lo /usr/local/bin/docker-compose${VERSION}/docker-compose-`uname -s`-`uname -m` \
 && chmod +x /usr/local/bin/docker-compose

Shell versus Exec Notation

Shell notation wraps command in shell:

RUN java -version   # sh -c 'java -version'

Exec notation starts process without shell:

FROM openjdk:11-jre
CMD [ "java", "-version" ]

Equivalent to…

docker run -it openjdk:11-jre java -version


ENTRYPOINT defined process

CMD defines parameters

FROM openjdk:11-jre
ENTRYPOINT [ "java" ]
CMD [ "-version" ]

Override parameters from the command line:

docker build --tag java .
docker run -it java -help

Image registries

Docker Hub is not the only source for images

Private registries based on Docker Distribution

docker tag java nicholasdille/java
docker push nicholasdille/java

You must be logged in to Docker Hub and push to a repository owned by the account

Private registries


localhost:5000 is preconfigured as insecure registry

Other registries must be secure (HTTPS)

docker run -d --name registry -p 5000:5000 registry
docker tag java localhost:5000/java
docker push localhost:5000/java