Dockerfile
A 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 FROM
Instructions
Section titled “Instructions”Each line of a Dockerfile can contain instructions that will incrementally build the image.
FROM httpd:2.4FROM 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.4COPY ./public/ /usr/local/apache2/htdocs/COPY will copy from the local file system to the image file system.
Building
Section titled “Building”The 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.048kBStep 1/1 : FROM httpd:2.4 ---> b2c2ab6dcf2eSuccessfully built b2c2ab6dcf2eIt will give feedback on each step of the Dockerfile.
Give your image a tag via using the --tag option.
$ docker build . --tag magicmonster/exampleSending build context to Docker daemon 2.048kBStep 1/1 : FROM httpd:2.4 ---> b2c2ab6dcf2eSuccessfully built b2c2ab6dcf2eSuccessfully tagged magicmonster/example:latestIn the above the example the image name is magicmonster/example and tag is magicmonster/example:latest.
References
Section titled “References”- Dockerfile reference
- console help
docker build --help