dockerfile-simple file
# base image
FROM ubuntu:20.04
# install jq
RUN apt-get update \
&& apt-get install -y jq \
&& rm -rf /var/lib/apt/lists/*
dockerfile-with-heredoc file
# syntax=docker/dockerfile:1.3-labs
# base image
FROM ubuntu:20.04
# install jq
RUN <<EOF
apt-get update
apt-get install -y jq
rm -rf /var/lib/apt/lists/*
EOF
dockerfile-python file
# syntax=docker/dockerfile:1.3-labs
# base image
FROM python:3.9.7-alpine
# using heredoc to create hello file
RUN python3 <<EOF > /hello
print("Hello")
print("World!")
EOF
dockerfile-nginx file
# syntax=docker/dockerfile:1.3-labs
# base image
FROM nginx:1.21.1
# using heredoc to create index.html file
COPY <<EOF /usr/share/nginx/html/index.html
Welcome to Community All-Hands
EOF
# create robots and humans files
COPY <<robots.txt <<humans.txt /usr/share/nginx/html/
User-agent: *
Disallow:
robots.txt
Manuel Morejon (Cloud Engineer)
https://mmorejon.io
@morejon85
humans.txt
docker image build --tag dockerfile-simple --file dockerfile-simple .
docker image build --tag dockerfile-with-heredoc --file dockerfile-with-heredoc .
docker image ls --filter \"reference=dockerfile-*\"
docker image history dockerfile-simple
docker image history dockerfile-with-heredoc
docker image build --tag dockerfile-python --file dockerfile-python .
docker container run --rm -it dockerfile-python cat /hello
docker image build --tag dockerfile-nginx --file dockerfile-nginx .
docker container run --rm --detach --publish 8080:80 dockerfile-nginx
curl localhost:8080
curl localhost:8080/robots.txt
curl localhost:8080/humans.txt