Dockerfile used to automate the work, indicating the whole step that we want on the docker image.
A Dockerfile is a text document containing all the commands that a user can invoke a command line to assemble an image. Using dockers, users can create an automatic assembly that runs several command prompts in sequence.
Yes, we can create Docker images, but every time we want to make any changes, you need to manually change and test and click.
or if you use a Dockerfile with dockerhub, then it will automatically rebuild and make changes with each modification, and if something is wrong, the rebuild will fail.
Dockerfile Benefits
- Dockerfile automated docker image script
- Creating a manual image will become difficult if you want to test the same setting for a different taste of the operating system, then you need to create an image for all tastes, but with a small change to the docker file, you can create images for different tastes.
- it has simple syntax for the image and makes many changes automatically, which will take more time when executed manually.
- Dockerfile has a systematic step that can be understood by others easily and easily to find out what exact configuration has changed in the base image.
Advantage of Dockerfile with dockerhub
- The Docker Hub provides a private repository for the Docker file.
- Dockerfile can be shared between team and organization.
- Automatic image assemblies
- Webhooks attached to your repositories that allow you to fire an event when an image or updated image is placed in the repository
- we can put a dockerfile on github or
Bitbucket
Difference Between Fixed Image and Dockerfile Image
Fixed image : it commits changes or settings of container files to a new image.
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] Create a new image from a container changes -a,
A good option for debugging the container and exporting changed the settings to another image. But docker suggests using dockerfile here or we can say that commit is a version of docker or an image backup.
The commit operation will not contain any data contained in the volumes installed inside the container.
By default, the transmitted container and its processes will be suspended while the image is frozen. This reduces the chance of encountering data corruption during the creation process to commit. If this behavior is not desired, set the p parameter to false.
Dockerfile based image:
he always uses the base image to create a new image. Suppose that if you made any changes to the dockerfile, then it will apply all the steps of the docker file in the new image and create a new image. but use the same image.
From my point of view, we should use a dockerfile that has all the steps that we want on the image, but if we create the image from a commit, we should document all the changes we made that might be required if we want to create a new image and we can say that the dockerfile is image documentation.