[VIDEO] Creare un immagine da un docker file

Not reviewed notes

How to build image from docker file

vim Dockerfile //this is the default docker file name


FROM centos:latest
LABEL mantainer=”[email protected]

RUN yum update -y

docker build -t customimage:v1 .//-t = tag, . is context (the current directory)

docker images //and i can see customimage:v1 in list

If i build image again, docker uses cache so it’s built immediately

If i modify a level (eg the email) in docker file, it won’t use cache and intermedie level are rebuilt.

cp Dockerfile Dockerfile1


FROM ubuntu:latest
LABEL mantainer=”[email protected]

RUN apt-get update -y

docker build -t customubuntu:v1 -f Dockerfile1 .//-f is for non standard docker file name

docker build –pull –no-cache –squash -t newimage:v1 .//–pull pull image even if exists in local repo, –no-cache won’t use cache, –squash force image to one layer

Squash is experimental feature! Doesn’t work in production enviroment