Dockerfile Benefits

We can create Docker images, and all of them click on a hub without a Docker file. Why is it useful to have a docker file? What are the benefits of this? Creating a docker file is a time-consuming process and can only be created by humans. I would like to know what is the main difference between the base image, the fixed image and the Dockerfile based image.

+5
source share
3 answers

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, --author= Author (eg, "John Hannibal Smith < hannibal@a-team.com >") -c, --change=[] Apply Dockerfile instruction to the created image --help=false Print usage -m, --message= Commit message -p, --pause=true Pause container during commit 

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.

+3
source

The advantage is that even if you don’t have registries of shared images that you could click your images on, you can still exchange images using a β€œrecipe” ( Dockerfile used by docker build ), which is just a couple of KB of text and can be easily transmitted (light and small).

This declarative format ensures that you can restore an identical image and ensure reproducible results.

+2
source

Docker alignment

Using the Docker commit command to create new images is error prone, you need to remember and update the image for minor changes and commit every time.

Dockerfile

  • Dockerfile provides the ability to automate all stages with a set of directives that are executed during the build (see the docker build command) to create the final image along with image capture.

  • Dockerfile is used everywhere, everything is configured and ready to go.

  • Dockerfile can be shared with other users and easily updated by others. This allows you to easily change the image depending on the requirements, for example, simplifying security, adding or updating user data, etc.

0
source

Source: https://habr.com/ru/post/1232849/


All Articles