Dockerfile is a list of steps used to build an image.
It can be stored with build scripts of an application.
Each line in the
Dockerfile is a step that docker will execute when building the image.
The first line is usually a
Each line of a
Dockerfile can contain instructions that will incrementally build the image.
FROM will start the image from the specified base or parent image. If there are no more instructions following, then
the build image will be the same as the base image.
FROM httpd:2.4 COPY ./public/ /usr/local/apache2/htdocs/
COPY will copy from the local file system to the image file system.
docker client can build the image and store it on the server.
To build an image using the
Dockerfile in the current directory, run
docker build .
$ docker build . Sending build context to Docker daemon 2.048kB Step 1/1 : FROM httpd:2.4 ---> b2c2ab6dcf2e Successfully built b2c2ab6dcf2e
It will give feedback on each step of the
Give your image a tag via using the
$ docker build . --tag magicmonster/example Sending build context to Docker daemon 2.048kB Step 1/1 : FROM httpd:2.4 ---> b2c2ab6dcf2e Successfully built b2c2ab6dcf2e Successfully tagged magicmonster/example:latest
In the above the example the image name is
magicmonster/example and tag is
- Dockerfile reference
- console help
docker build --help