What Goes Into a Dockerfile?

Build a Dockerfile from the ground up, no experience necessary

Dieter Jordens
Jan 22 · 13 min read
Photo by justin beck on Unsplash

What Is Docker?


FROM

FROM <image>[:tag]
FROM ubuntu

RUN

Photo by Bruno Nascimento on Unsplash

CMD


COPY


ADD

Extracting a TAR file

Using a URL


WORKDIR

Impacted instructions of the WORKDIR instruction

ENTRYPOINT

FROM ubuntu
ENTRYPOINT ls

ENV

FROM ubuntu
ENV workdir=/root/
CMD echo $workdir

LABEL

docker images --filter label=description="Baby don't hurt me."
ID: 2de9f0eddcfd

HEALTHCHECK

docker ps
Status: Up 5 seconds (health: starting)
docker ps
Status: Up 9 seconds (health: starting)
docker ps
Status: Up 11 seconds (unhealthy)
docker ps
Status: Up About a minute (healthy)

STOPSIGNAL

FROM ubuntu
STOPSIGNAL SIGKILL
docker ps
docker stop 50b3f43b5588

VOLUME


EXPOSE


Conclusion

Photo by Jp Valery on Unsplash

Better Programming

Advice for programmers.

Dieter Jordens

Written by

Dieter is passionate about full stack agile software development and artificial intelligence. He is working as a Software Crafter at Continuum Consulting.

Better Programming

Advice for programmers.

More From Medium

More from Better Programming

More from Better Programming

More from Better Programming

More from Better Programming

Why Do Incompetent Managers Get Promoted?

1.2K

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade