I’ve been asked these questions quite a few times and I am confused about how to explain it in layman’s term, but again if you can’t explain it to a 5 yr old, you don’t understand it yourself.
Dockerfile:
A Dockerfile
is a text document that contains all the commands a user could call on the command line to assemble an image. We use the Dockerfile using the “Build” command to build an image from the dockerfile. The docker build
command builds an image from a Dockerfile
and a context. The build’s context is the set of files at a specified location PATH
or URL
.
Docker Image:
Docker images are created from a Dockerfile
with the docker build
command. Docker images can either be built from a Dockerfile (which usually pulls a base image and builds on top of it) or can be pulled from a stored location like a Docker registry. Docker images themselves are never “started” and never “running”. The docker run command takes the Docker image as a template and produces a container from it.
A Docker image is a compressed, self-contained piece of software which has to be unwrapped in order to use the functionality. This Image may contain any Software, Operating System, Service., etc
Docker Layers:
Docker images are designed to be composed of a series of layers. Each instruction in a Dockerfile creates a layer in the image. Each layer is a set of differences from the previous layer.
Docker Containers:
To create a container, Docker engine takes an image, adds the top writable layer and initializes various settings (network ports, container name, ID and resource limits). All write operation inside the container are stored in this writable layer, so when the container is deleted, the writable layer is also deleted while the underlying image remains unchanged. The main difference between a container and an image is the top writable layer.
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
A docker container is a runnable instance of a docker image.