Images
Basic Dockerfile example
LABEL maintainer="Yaroslav Grebnov" version="1.0"
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
Use variables in Dockerfile
Variables in Dockerfile to be used during image building
ARG
Not cached
Variables in Dockerfile to be used during container running
ENV
Cached
Variables in Dockerfile to be used during both, image building and container running
ARG var
ENV var=${var}
Variable expansion in Dockerfile
COPY {var,,}
Remove dangling images
docker rmi $(docker image ls -f "dangling=true" -q)
Command explantion:
docker image ls
lists images-f
stands forfilter
. So,-f "dangling=true"
selects only the dangling images-q
stands forquiet
, which means that only the images IDs (hashes) are returneddocker rmi
removes a list of selected images